My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
Creator of elementary functions in C Sharp
Posted Date:
Total Responses: 0
Posted By: Mahesh Member Level: Platinum Points/Cash: 6
|
using System; using System.Collections.Generic; using System.Collections; using System.Text;
namespace FormulaEditor { /// /// Creator of elementary functions /// public class ElementaryFunctionsCreator : IFormulaObjectCreator {
public static readonly ElementaryFunctionsCreator Object = new ElementaryFunctionsCreator(true);
protected ArrayList unaryDetectors = new ArrayList(); protected IBinaryDetector[] detectors;
const Double a = 0;
private IMultiOperationDetector[] multiDetectors = new IMultiOperationDetector[] { OptionalDetector.Object };
protected ElementaryFunctionsCreator() : this(true) { }
protected ElementaryFunctionsCreator(bool init) { if (!init) { return; } ElementaryBinaryDetector plus = new ElementaryBinaryDetector('+'); plus.Add(StringConcatOperation.Object); plus.Add(StringObjectConcatOperation.Object); LikeOperation like = new LikeOperation(); like.Add(LikeObjectOperation.Object);
detectors = new IBinaryDetector[] { new LogicalDetector('\u2217'), new LogicalDetector('\u2216'), LogicalEqualityDetector.Object, new BitDetector('|'), new BitDetector('&'), new BitDetector('^'), new BitDetector('\u2266'), new BitDetector('\u2267'), ComparationDetector.Object, like, plus, new ElementaryBinaryDetector('-'), new ElementaryBinaryDetector('*') }; }
/// /// Count of binary operations /// public virtual int BinaryCount { get { return detectors.Length; } } /// /// Gets i - th binary detector /// /// Detector number /// The i - th detector public virtual IBinaryDetector GetBinaryDetector(int i) { return detectors[i]; }
/// /// Checks whether symbol is bra /// /// The symbol /// True if symbol is bra and false otherwise public bool IsBra(MathSymbol s) { return s.Symbol == '('; }
/// /// Checks whether symbol is ket /// /// The symbol /// True if symbol is ket and false otherwise public bool IsKet(MathSymbol s) { return s.Symbol == ')'; }
/// /// Count of operations /// public virtual int OperationCount { get { return unaryDetectors.Count + 1; } }
/// /// Gets i - th operation detector /// /// Detector number /// The i - th detector public virtual IOperationDetector GetDetector(int i) { if (i == 0) { return ElementaryRealDetector.Object; } return unaryDetectors[i - 1] as IOperationDetector; }
/// /// Adds unary operation detector /// /// Detector to add public void Add(IOperationDetector detector) { unaryDetectors.Add(detector); }
/// /// Count of multi operation /// public int MultiOperationCount { get { return multiDetectors.Length; } }
/// /// Gets multi operation detector /// /// The detector number /// The n - th detector public IMultiOperationDetector GetMultiOperationDetector(int n) { return multiDetectors[n]; }
/// /// Gets power operation /// /// Type of value /// Type of power /// Operation public virtual IObjectOperation GetPowerOperation(object valType, object powType) { if (valType.Equals(a) & powType.Equals(a)) { return new ElementaryPowerOperation(valType, powType); } return null; } } }
|
Project Feedbacks
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|
|
|
| Post Feedback |
|
|
You must Sign In to post a feedback.
|
|
|
|
|
Advertise Here
|