private static IDictionary<IAttributeDefinition, object> CheckApplication(IBaseObject instance) { var od = AppCore.AppSingleton.FindObjDef<ApplicationObjDef>(); IDictionary<IAttributeDefinition, object> changes = new Dictionary<IAttributeDefinition, object>(); if (!(instance is ApplicationProxy)) Debug.Assert(false, "The given instance is not proxy type."); var entity = instance as ApplicationProxy; var orginal = entity.Original as ApplicationProxy; if (entity.ID != orginal.ID) changes.Add(od.PrimaryKey, entity.ID); if (entity.customerId != orginal.customerId) changes.Add(od.CustomerID, entity.customerId); if (entity.Region != orginal.Region) changes.Add(od.Region, entity.Region); if (entity.DateApplied != orginal.DateApplied) changes.Add(od.DateApplied, entity.DateApplied); if (entity.DateTraved != orginal.DateTraved) changes.Add(od.DateTraved, entity.DateTraved); if (entity.OffNoteNo != orginal.OffNoteNo) changes.Add(od.OffNoteNo, entity.OffNoteNo); if (entity.OffNoteDate != orginal.OffNoteDate) changes.Add(od.OffNoteDate, entity.OffNoteDate); if (entity.Remark != orginal.Remark) changes.Add(od.Remark, entity.Remark); return changes; }
/// <summary> /// Adds object to phantom elements list. /// </summary> /// <param name="baseObject"> /// Object to add. /// </param> /// <returns> /// Index of new element or -1 if element not added. /// </returns> public override int Add(IBaseObject baseObject) { if (baseObject != null && !baseObject.Equals(NullValue.Instance())) { return base.Add(baseObject); } return -1; }
internal SceneElement(IBaseObject x) : base(x) { if (parameterBlock == null) { IIParamArray pa = _BaseObject.ParamBlock; if (pa != null) parameterBlock = CreateWrapper<ParameterBlock1>(pa.ParamBlock); } }
/// <summary> /// Addes chain to alphabet. /// </summary> /// <param name="item"> /// The item. /// </param> /// <returns> /// <see cref="int"/>. /// </returns> public override int Add(IBaseObject item) { var temp = item as BaseChain; if (temp == null) { temp = new BaseChain(1); temp.Set(item, 0); } return base.Add(temp); }
/// <summary> /// Initializes a new instance of the <see cref="BinaryIntervalsManager"/> class. /// </summary> /// <param name="firstChain"> /// The first chain. /// </param> /// <param name="secondChain"> /// The second chain. /// </param> public BinaryIntervalsManager(CongenericChain firstChain, CongenericChain secondChain) { FirstElement = firstChain.Element; SecondElement = secondChain.Element; FirstChain = firstChain; SecondChain = secondChain; Length = firstChain.GetLength(); PairsCount = FillPairsCount(); relationIntervals = new int[PairsCount]; FillIntervals(); }
/// <summary> /// Initializes a new instance of the <see cref="TreeNode"/> class. /// </summary> /// <param name="parent"> /// Parent node. /// </param> /// <param name="content"> /// Content of the this node. /// </param> /// <param name="table"> /// Parameters table. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if parent is null. /// </exception> public TreeNode(AbstractNode parent, IBaseObject content, PhantomTable table) { if (parent == null) { throw new ArgumentNullException("parent", "Parent node is null"); } this.parent = parent; Level = this.parent.Level + 1; Volume = table[Level + 1].Volume; id = content; StartPosition = table.StartPositions[Level]; }
private static IDictionary<IAttributeDefinition, object> CheckCase(IBaseObject instance) { var od = AppCore.AppSingleton.FindObjDef<CaseObjDef>(); IDictionary<IAttributeDefinition, object> changes = new Dictionary<IAttributeDefinition, object>(); if (!(instance is CaseProxy)) Debug.Assert(false, "The given instance is not proxy type."); var entity = instance as CaseProxy; var orginal = entity.Original as CaseProxy; //if(entity.AppId!=orginal.AppId) // changes.Add(od.PrimaryKey, entity.AppId); if(entity.Type!=orginal.Type) changes.Add(od.Type,entity.Type); if(entity.Text!=orginal.Text) changes.Add(od.Text,entity.Text); return changes; }
public static IDictionary<IAttributeDefinition, object> Check(string entityName, IBaseObject instance) { switch (entityName) { case "Application": return CheckApplication(instance); case "Customer": return CheckCustomer(instance); case "User": return CheckUser(instance); case "Case": return CheckCase(instance); case "Collection": return CheckCollection(instance); case "Status": return CheckStatus(instance); default: Debug.Assert(false, "Didn't implement entity check for the entity " + entityName); return null; } }
/// <summary> /// Gets or creates congeneric chain. /// </summary> /// <param name="element"> /// The element of congeneric chain. /// </param> /// <returns> /// The <see cref="CongenericChain"/>. /// </returns> public CongenericChain GetOrCreateCongenericChain(IBaseObject element) { return TryGetCongenericChain(element) ?? new CongenericChain(element); }
public void Update(IBaseObject baseObject) { EventDao.Update(baseObject); }
public ActionResult Index(long matterId, Notation notation, Language?language, Translator?translator, PauseTreatment?pauseTreatment, bool?sequentialTransfer, int scrambling) { Matter matter = db.Matter.Single(m => m.Id == matterId); long sequenceId; switch (matter.Nature) { case Nature.Literature: sequenceId = db.LiteratureSequence.Single(l => l.MatterId == matterId && l.Notation == notation && l.Language == language && l.Translator == translator).Id; break; case Nature.Music: sequenceId = db.MusicSequence.Single(m => m.MatterId == matterId && m.Notation == notation && m.PauseTreatment == pauseTreatment && m.SequentialTransfer == sequentialTransfer).Id; break; default: sequenceId = db.CommonSequence.Single(c => c.MatterId == matterId && c.Notation == notation).Id; break; } BaseChain chain = sequenceRepository.GetLibiadaBaseChain(sequenceId); for (int i = 0; i < scrambling; i++) { int firstIndex = randomGenerator.Next(chain.Length); int secondIndex = randomGenerator.Next(chain.Length); IBaseObject firstElement = chain[firstIndex]; IBaseObject secondElement = chain[secondIndex]; chain[firstIndex] = secondElement; chain[secondIndex] = firstElement; } var resultMatter = new Matter { Nature = matter.Nature, Name = $"{matter.Name} {scrambling} mixes" }; db.Matter.Add(resultMatter); db.SaveChanges(); var result = new CommonSequence { Notation = notation, MatterId = resultMatter.Id }; long[] alphabet = elementRepository.ToDbElements(chain.Alphabet, notation, false); switch (matter.Nature) { case Nature.Genetic: DnaSequence dnaSequence = db.DnaSequence.Single(c => c.Id == sequenceId); dnaSequenceRepository.Create(result, dnaSequence.Partial, alphabet, chain.Building); break; case Nature.Music: musicSequenceRepository.Create(result, alphabet, chain.Building); break; case Nature.Literature: LiteratureSequence sequence = db.LiteratureSequence.Single(c => c.Id == sequenceId); literatureSequenceRepository.Create(result, sequence.Original, sequence.Language, sequence.Translator, alphabet, chain.Building); break; case Nature.MeasurementData: dataSequenceRepository.Create(result, alphabet, chain.Building); break; default: throw new InvalidEnumArgumentException(nameof(matter.Nature), (int)matter.Nature, typeof(Nature)); } return(RedirectToAction("Index", "Matters")); }
/// <summary> /// Sets item in provided position. /// Clears position if element not from this chain. /// Does nothing if position is empty and element not from this chain. /// </summary> /// <param name="item"> /// The item. /// </param> /// <param name="index"> /// The index of position. /// </param> public override void Set(IBaseObject item, int index) { if (element.Equals(item)) { Set(index); } }
/// <summary> /// Sets a value into current iterator position. /// </summary> /// <param name="value"> /// Value to write into current position of iterator. /// </param> public void WriteValue(IBaseObject value) { Source.Set(value, Position); }
public IllegalThreadException(IBaseObject baseObject, string callerName) : base( $"{callerName} from {baseObject} called in wrong thread with name {Thread.CurrentThread.Name} and id {Thread.CurrentThread.ManagedThreadId}") { }
public bool CheckAccess(IBaseObject requestedObject, User requester, Access requested) { }
/// <summary> /// The equals as element. /// </summary> /// <param name="baseObject"> /// The base object. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private bool EqualsAsElement(IBaseObject baseObject) { for (int i = 0; i < Cardinality; i++) { if (IndexOf(baseObject) != -1) { return true; } } return false; }
/// <summary> /// Initializes a new instance of the <see cref="CongenericChain"/> class. /// </summary> /// <param name="element"> /// Element of this congeneric sequence. /// </param> /// <param name="length"> /// Length of this chain. /// </param> public CongenericChain(IBaseObject element, int length) { this.element = element; this.length = length; positions = new List<int>(); }
/// <summary> /// Fills clone of this chain. /// </summary> /// <param name="clone"> /// The clone of chain. /// </param> protected void FillClone(IBaseObject clone) { var tempChain = clone as Chain; base.FillClone(tempChain); if (tempChain != null) { if (congenericChains != null) { tempChain.congenericChains = (CongenericChain[])congenericChains.Clone(); } } }
/// <summary> /// Initializes a new instance of the <see cref="CongenericChain"/> class. /// </summary> /// <param name="element"> /// The element. /// </param> public CongenericChain(IBaseObject element) { this.element = element; length = 0; positions = new List<int>(); }
/// <summary> /// Tries to get congeneric chain. /// if there is no such chain returns null. /// </summary> /// <param name="element"> /// The element of seeked congeneric chain. /// </param> /// <returns> /// The <see cref="CongenericChain"/>. /// </returns> public CongenericChain TryGetCongenericChain(IBaseObject element) { if (!alphabet.Contains(element)) { return null; } return CongenericChain(element); }
/// <summary> /// Sets item in provided position. /// </summary> /// <param name="item"> /// The item. /// </param> /// <param name="index"> /// The index. /// </param> public override void Set(IBaseObject item, int index) { base.Set(item, index); congenericChains = null; }
/// <summary> /// The get relation intervals manager. /// </summary> /// <param name="first"> /// The first. /// </param> /// <param name="second"> /// The second. /// </param> /// <returns> /// The <see cref="BinaryIntervalsManager"/>. /// </returns> public BinaryIntervalsManager GetRelationIntervalsManager(IBaseObject first, IBaseObject second) { return GetRelationIntervalsManager(alphabet.IndexOf(first), alphabet.IndexOf(second)); }
public static void Add(IBaseObject obj) { objects.Add(obj); }
private static void Main(string[] args) { ResultTypeStankins[] refs = FindAssembliesToExecute.AddReferences(new FindAssembliesToExecute(null).FromType(typeof(RecipeFromFilePath))); CtorDictionaryGeneric <ResultTypeStankins> commands = new CtorDictionaryGeneric <ResultTypeStankins>(); Action <ResultTypeStankins> createItem = (t) => { if (commands.ContainsKey(t.Name)) { System.Console.WriteLine($"key exists : {t.Name}"); } else { commands.Add(t.Name, t); } }; foreach (ResultTypeStankins item in refs) { createItem(item); } CommandLineApplication app = new CommandLineApplication { Name = "Stankins.Console" }; string versionString = Assembly.GetEntryAssembly() .GetCustomAttribute <AssemblyInformationalVersionAttribute>() .InformationalVersion .ToString(); app.HelpOption("-?|-h|--help"); app.VersionOption("-v|--version", app.Name + "v" + versionString, app.Name + "v" + versionString); app.ExtendedHelpText = ExtendedHelpText(); //app.Command("list", (command) => //{ // command.Description = "List all supported objects"; // command.HelpOption("-?|- h|--help"); // command.OnExecute(() => // { // var all = commands.Select(it => it.Key.ToString()).ToList(); // all.Sort(); // all.ForEach(it => System.Console.WriteLine(it)); // return 0; // }); //}); app.Command("recipes", (command) => { command.Description = "execute/list recipes already in system"; CommandOption list = command.Option("-l|--list", "list recipes", CommandOptionType.NoValue); CommandOption execute = command.Option("-e|--execute", "execute recipe", CommandOptionType.SingleValue); command.OnExecute(async() => { if (list.HasValue()) { List <Recipe> recipes = RecipeFromString.RecipesFromFolder().ToList(); recipes.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (Recipe item in recipes) { System.Console.WriteLine($"Stankins.Console recipes -e {item.Name}"); } return(0); } if (execute.HasValue()) { string recipeString = execute.Value(); RecipeFromString recipe = RecipeFromString.FindRecipe(recipeString); if (recipe == null) { System.Console.Error.WriteLine($"can not found {recipeString}"); return(0);//maybe return error? } await recipe.TransformData(null); return(0); } command.ShowHelp(); return(0); }); }); app.Command("list", (command) => { string names = string.Join(',', Enum.GetNames(typeof(WhatToList))); command.Description = "Explain arguments for supported objects - could be " + names; command.HelpOption("-?|-h|--help"); CommandOption optWhat = command.Option("-what", "what to list", CommandOptionType.SingleValue); command.OnExecute(() => { if (!optWhat.HasValue()) { System.Console.WriteLine("please add -what " + names); return(-1); } WhatToList val = (WhatToList)(int)Enum.Parse(typeof(WhatToList), optWhat.Value(), true); List <ResultTypeStankins> all = commands.Select(it => it.Value).ToList(); List <ResultTypeStankins> find = all.Where(it => val == (val & it.FromType())).ToList(); find.Sort((a, b) => a.Name.CompareTo(b.Name)); WriteLines(find.ToArray()); System.Console.WriteLine(""); System.Console.WriteLine("!for often used commands , see -h option"); return(0); }); }); app.Command("files", (command) => { command.Description = "Execute file "; command.HelpOption("-?|-h|--help"); CommandOption opt = command.Option("-f", "execute file ", CommandOptionType.MultipleValue); command.OnExecute(async() => { if (!opt.HasValue()) { System.Console.WriteLine("please add -f fileName"); return(0); } int lenValuesCount = opt.Values.Count; for (int i = 0; i < lenValuesCount; i++) { string fileName = opt.Values[i]; System.Console.WriteLine($"executing {fileName}"); string text = await File.ReadAllTextAsync(fileName); var r = new RecipeFromString(text); await r.TransformData(null); } return(0); }); }); app.Command("cron", (command) => { command.Description = "Execute CRON file uninterrupted "; command.HelpOption("-?|-h|--help"); CommandOption opt = command.Option("-d", "directory with cron files", CommandOptionType.SingleValue); command.OnExecute(async() => { if (!opt.HasValue()) { System.Console.WriteLine("please add -d directoryname"); return(0); } var dir = opt.Value(); var r = new RunCRONFiles(dir); var ct = new CancellationTokenSource(); var token = ct.Token; #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed r.StartAsync(token); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed System.Console.WriteLine("press any key to shutdown"); var s = System.Console.ReadKey(); ct.Cancel(); await Task.Delay(3000); return(0); }); }); app.Command("execute", (command) => { command.Description = "Execute multiple "; command.HelpOption("-?|-h|--help"); CommandOption opt = command.Option("-o", "execute object", CommandOptionType.MultipleValue); CommandOption argObjects = command.Option("-a", "arguments for the object", CommandOptionType.MultipleValue); //var locationArgument = command.Argument("[location]", "The object to execute -see list command ", true); command.OnExecute(async() => { if (!opt.HasValue()) { System.Console.WriteLine("see list command for objects"); return(0); } int argNr = 0; int lenValuesCount = opt.Values.Count; for (int i = 0; i < lenValuesCount; i++) { string item = opt.Values[i].ToLowerInvariant(); if (!commands.ContainsKey(item)) { System.Console.WriteLine($"not an existing object {item} - please see list command"); return(-1); } argNr += commands[item].ConstructorParam.Count; } if (argNr != argObjects.Values.Count) { System.Console.WriteLine($"not equal nr args -a {lenValuesCount} with nr args for objects {argNr} - please see list command"); return(-1); } IBaseObject last = null; IDataToSent data = null; argNr = 0; for (int value = 0; value < lenValuesCount; value++) { string item = opt.Values[value].ToLowerInvariant(); ResultTypeStankins cmd = commands[item]; object[] ctorArgs = null; if (cmd.ConstructorParam.Count > 0) { ctorArgs = new object[cmd.ConstructorParam.Count]; int i = 0; do { string item1 = argObjects.Values[argNr]; ctorArgs[i] = item1; i++; argNr++; } while (i < cmd.ConstructorParam.Count); } last = cmd.Create(ctorArgs); data = await last.TransformData(data); } ISenderToOutput output = last as ISenderToOutput; if (output != null) { System.Console.WriteLine("exporting default output ?"); //TODO: add option for this SenderOutputToFolder sender = new SenderOutputToFolder("", true); data = await sender.TransformData(data); } else { System.Console.WriteLine("exporting all tables to csv ? "); //TODO: add option for this //await new SenderAllTablesToFileCSV("").TransformData(data); } return(0); }); } ); if (args?.Length < 1) { app.ShowRootCommandFullNameAndVersion(); app.ShowHint(); return; } app.Execute(args); }
public static void Remove(IBaseObject obj) { objects.Remove(obj); }
public void Insert(IBaseObject baseObject) { OccassionDao.Insert(baseObject); }
/// <summary> /// Returns clone of congeneric sequence of given element. /// If there is no such element in chain returns null. /// </summary> /// <param name="baseObject"> /// Element of congeneric chain. /// </param> /// <returns> /// The <see cref="T:CongenericChain"/>. /// </returns> public CongenericChain CongenericChain(IBaseObject baseObject) { if (congenericChains == null) { FillCongenericChains(); } CongenericChain result = null; int pos = Alphabet.IndexOf(baseObject); if (pos != -1) { result = (CongenericChain)congenericChains[pos].Clone(); } return result; }
public void Remove(IBaseObject item) { Remove(item.Id); }
/// <summary> /// Sets or replaces element in specified position. /// </summary> /// <param name="item"> /// Element to set. /// </param> /// <param name="index"> /// Position in sequence. /// </param> public override void Set(IBaseObject item, int index) { if (item == null) { throw new NullReferenceException(); } RemoveAt(index); int position = alphabet.IndexOf(item); if (position == -1) { alphabet.Add(item); position = alphabet.Cardinality - 1; } building[index] = position; }
public virtual void HeartbeatBigTick(IBaseObject performer) { //do nothing unless overrode }
private static IDictionary<IAttributeDefinition, object> CheckCustomer(IBaseObject instance) { var od = AppCore.AppSingleton.FindObjDef<CustomerObjDef>(); IDictionary<IAttributeDefinition, object> changes = new Dictionary<IAttributeDefinition, object>(); if (!(instance is CustomerProxy)) Debug.Assert(false, "The given instance is not proxy type."); var entity = instance as CustomerProxy; var orginal = entity.Original as CustomerProxy; if (entity.ID != orginal.ID) changes.Add(od.PrimaryKey, entity.ID); if (entity.Name != orginal.Name) changes.Add(od.Name, entity.Name); if (entity.Sex != orginal.Sex) changes.Add(od.Sex, entity.Sex); if (entity.Phone != orginal.Phone) changes.Add(od.Phone, entity.Phone); if (entity.Address != orginal.Address) changes.Add(od.Address, entity.Address); return changes; }
public void Insert(IBaseObject baseObject) { EventDao.Insert(baseObject); }
private static IDictionary<IAttributeDefinition, object> CheckUser(IBaseObject instance) { var od = AppCore.AppSingleton.FindObjDef<UserObjDef>(); IDictionary<IAttributeDefinition, object> changes = new Dictionary<IAttributeDefinition, object>(); if (!(instance is UserProxy)) Debug.Assert(false, "The given instance is not proxy type."); var entity = instance as UserProxy; var orginal = entity.Original as UserProxy; if(entity.ID!=orginal.ID) changes.Add(od.PrimaryKey,entity.ID); if (entity.Name != orginal.Name) changes.Add(od.Name, entity.Name); if (entity.Password != orginal.Password) changes.Add(od.Password, entity.Password); if (entity.Role != orginal.Role) changes.Add(od.Role, entity.Role); return changes; }
public ActionResult Index( long[] matterIds, int characteristicLinkId, Notation notation, Language?language, Translator?translator, PauseTreatment?pauseTreatment, bool?sequentialTransfer, ImageOrderExtractor?trajectory, string calculationType) { return(CreateTask(() => { if (matterIds.Length != 2) { throw new ArgumentException("Number of selected matters must be 2.", nameof(matterIds)); } var characteristics = new Dictionary <int, Dictionary <int, double> >(); string characteristicName = characteristicTypeLinkRepository.GetCharacteristicName(characteristicLinkId, notation); var result = new Dictionary <string, object> { { "characteristics", characteristics }, { "matterNames", Cache.GetInstance().Matters.Where(m => matterIds.Contains(m.Id)).Select(m => m.Name).ToList() }, { "characteristicName", characteristicName }, { "calculationType", calculationType } }; var sequenceIds = commonSequenceRepository.GetSequenceIds(matterIds, notation, language, translator, pauseTreatment, sequentialTransfer, trajectory); Chain firstChain = commonSequenceRepository.GetLibiadaChain(sequenceIds[0]); Chain secondChain = commonSequenceRepository.GetLibiadaChain(sequenceIds[1]); AccordanceCharacteristic accordanceCharacteristic = characteristicTypeLinkRepository.GetCharacteristic(characteristicLinkId); IAccordanceCalculator calculator = AccordanceCalculatorsFactory.CreateCalculator(accordanceCharacteristic); Link link = characteristicTypeLinkRepository.GetLinkForCharacteristic(characteristicLinkId); Alphabet firstChainAlphabet = firstChain.Alphabet; Alphabet secondChainAlphabet = secondChain.Alphabet; switch (calculationType) { case "Equality": if (!firstChainAlphabet.SetEquals(secondChainAlphabet)) { throw new Exception("Alphabets of sequences are not equal."); } characteristics.Add(0, new Dictionary <int, double>()); characteristics.Add(1, new Dictionary <int, double>()); var alphabet = new List <string>(); for (int i = 0; i < firstChainAlphabet.Cardinality; i++) { IBaseObject element = firstChainAlphabet[i]; alphabet.Add(element.ToString()); CongenericChain firstCongenericChain = firstChain.CongenericChain(element); CongenericChain secondCongenericChain = secondChain.CongenericChain(element); double characteristicValue = calculator.Calculate(firstCongenericChain, secondCongenericChain, link); characteristics[0].Add(i, characteristicValue); characteristicValue = calculator.Calculate(secondCongenericChain, firstCongenericChain, link); characteristics[1].Add(i, characteristicValue); } result.Add("alphabet", alphabet); break; case "All": var firstAlphabet = new List <string>(); for (int i = 0; i < firstChain.Alphabet.Cardinality; i++) { characteristics.Add(i, new Dictionary <int, double>()); IBaseObject firstElement = firstChainAlphabet[i]; firstAlphabet.Add(firstElement.ToString()); for (int j = 0; j < secondChainAlphabet.Cardinality; j++) { var secondElement = secondChainAlphabet[j]; var firstCongenericChain = firstChain.CongenericChain(firstElement); var secondCongenericChain = secondChain.CongenericChain(secondElement); var characteristicValue = calculator.Calculate(firstCongenericChain, secondCongenericChain, link); characteristics[i].Add(j, characteristicValue); } } var secondAlphabet = new List <string>(); for (int j = 0; j < secondChainAlphabet.Cardinality; j++) { secondAlphabet.Add(secondChainAlphabet[j].ToString()); } result.Add("firstAlphabet", firstAlphabet); result.Add("secondAlphabet", secondAlphabet); break; case "Specified": throw new NotImplementedException(); default: throw new ArgumentException("Calculation type is not implemented", nameof(calculationType)); } return new Dictionary <string, string> { { "data", JsonConvert.SerializeObject(result) } }; })); }
/// <summary> /// Initializes a new instance of the <see cref="CongenericChain"/> class. /// </summary> /// <param name="map"> /// The map of elements. /// </param> /// <param name="element"> /// Element of this congeneric sequence. /// </param> public CongenericChain(bool[] map, IBaseObject element) { length = map.Length; this.element = element; for (int i = 0; i < map.Length; i++) { if (map[i]) { Set(i); } } }
public bool RemoveObject(IBaseObject obj) { this.ObjectsChanged(this, new EventArgs()); return(this.Objects.Remove(obj)); }
/// <summary> /// Returns position of given occurrence of given element. /// </summary> /// <param name="element"> /// Element to find. /// </param> /// <param name="entry"> /// occurrence of given element. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public int GetOccurrence(IBaseObject element, int entry) { if (congenericChains == null) { FillCongenericChains(); } return congenericChains[alphabet.IndexOf(element) - 1].GetOccurrence(entry); }
void OnDestructed(IBaseObject ob) { var a = m_members.Single(ai => ai.Worker == ob); RemoveMember(a); }
public static string Goodbye(this IBaseObject obj) { return($"Goodbye {obj?.ToString()}!"); }
void OnControllableDestructed(IBaseObject ob) { var living = (LivingObject)ob; RemoveControllable(living); }
/// <summary> /// Initializes a new instance of the <see cref="CongenericChain"/> class. /// </summary> /// <param name="positions"> /// The positions of all elements in congeneric sequence. /// </param> /// <param name="element"> /// Element of this congeneric sequence. /// </param> /// <param name="length"> /// Length of this chain. /// </param> public CongenericChain(IEnumerable<int> positions, IBaseObject element, int length) { this.length = length; this.element = element.Clone(); this.positions = positions.OrderBy(b => b).ToList(); }
internal static void Update(IBaseObject baseObject) { throw new NotImplementedException(); }
public ActionResult Index( long matterId, short characteristicLinkId, Notation notation, int step, int initialLength, double accuracy) { return(CreateTask(() => { string characteristicName; string mattersName; double[] characteristics; Chain sequence; IFullCalculator calculator; Link link; using (var db = new LibiadaWebEntities()) { var commonSequenceRepository = new CommonSequenceRepository(db); mattersName = db.Matter.Single(m => matterId == m.Id).Name; var sequenceId = db.CommonSequence.Single(c => matterId == c.MatterId && c.Notation == notation).Id; sequence = commonSequenceRepository.GetLibiadaChain(sequenceId); var characteristicTypeLinkRepository = FullCharacteristicRepository.Instance; characteristicName = characteristicTypeLinkRepository.GetCharacteristicName(characteristicLinkId, notation); FullCharacteristic characteristic = characteristicTypeLinkRepository.GetCharacteristic(characteristicLinkId); calculator = FullCalculatorsFactory.CreateCalculator(characteristic); link = characteristicTypeLinkRepository.GetLinkForCharacteristic(characteristicLinkId); } // characteristics = SequencesCharacteristicsCalculator.Calculate( new[] { sequenceId }, characteristicLinkId); CutRule cutRule = new CutRuleWithFixedStart(sequence.Length, step); Depth depthCaulc = new Depth(); CutRuleIterator iter = cutRule.GetIterator(); var fragments = new List <Chain>(); var partNames = new List <string>(); var lengthes = new List <int>(); var teoreticalDepht = new List <double>(); while (iter.Next()) { var fragment = new Chain(iter.GetEndPosition() - iter.GetStartPosition()); for (int k = 0; iter.GetStartPosition() + k < iter.GetEndPosition(); k++) { fragment.Set(sequence[iter.GetStartPosition() + k], k); } fragments.Add(fragment); partNames.Add(fragment.ToString()); lengthes.Add(fragment.Length); teoreticalDepht.Add(depthCaulc.Calculate(fragment, Link.Start)); } characteristics = new double[fragments.Count]; for (int k = 0; k < fragments.Count; k++) { characteristics[k] = calculator.Calculate(fragments[k], link); // fragmentsData[k] = new FragmentData(characteristics, fragments[k].ToString(), starts[i][k], fragments[k].Length); } // var predicted = new List<Chain>(); //int[] startingPart = new int[initialLength]; Chain predicted = new Chain(initialLength); for (int i = 0; i < initialLength; i++) { predicted.Set(sequence[i], i); } Alphabet alphabet = sequence.Alphabet; IEnumerator enumerator = alphabet.GetEnumerator(); var sequencePredictionResult = new List <SequencePredictionData>(); for (int i = initialLength; i < sequence.Length; i++) { Chain temp = new Chain(i + 1); for (int j = 0; j < i; j++) { temp.Set(predicted[j], j); } predicted = temp; double depth = 0; /* do * { * predicted.Set((IBaseObject)enumerator.Current, i); * depth = depthCaulc.Calculate(predicted, Link.Start); * if (System.Math.Abs(depth - teoreticalDepht.ElementAt(i)) <= accuracy) * { * break; * } * } while (enumerator.MoveNext());*/ IBaseObject predictedLetter = null; foreach (IBaseObject letter in alphabet) { predicted.Set(letter, i); depth = depthCaulc.Calculate(predicted, Link.Start); if (System.Math.Abs(depth - teoreticalDepht.ElementAt(i)) <= accuracy) { predictedLetter = letter; break; } } sequencePredictionResult.Add(new SequencePredictionData { Fragment = fragments.ElementAt(i).ToString(), Predicted = /*enumerator.Current.ToString()*/ predicted.ToString(), ActualCharacteristic = depth, TheoreticalCharacteristic = teoreticalDepht.ElementAt(i) }); } /*int equal = 0; * for (int i = initialLength; i < sequence.Length; i++) * { * if (sequence[i] == predicted[i]) * { * equal++; * } * } * * * double accuracyPercentage = equal / (sequence.Length - initialLength);*/ // TODO: sequence prediction var result = new Dictionary <string, object> { { "result", sequencePredictionResult } }; return new Dictionary <string, object> { { "data", JsonConvert.SerializeObject(result) } }; })); }
public static XmlElement Save(IEnumerable <IBaseObject> list) { IBaseObject obj = list.DefaultIfEmpty(null).First(); // linq return(obj == null ? null : obj.Save(list)); }
public virtual void Init(IBaseObject iBaseObject) { }
public BaseObjectId(IBaseObject baseObject) { Zone = baseObject.Zone; Id = baseObject.Id; }
public bool Equals(IBaseObject other) { return(other != null && other.Id == Id); }
public static Task <bool> ExistsAsync(this IBaseObject baseObject) => AltVAsync.Schedule(() => baseObject.Exists);
//This method is very important for equality and comparison! //It is closely related to the constructor of Edge (there is some code duplication). private static string GetNodeIdFromParameters(IBaseObject parent, IBaseObject a, IBaseObject b) { var id = @""""; if (!parent.Root.IsDirected && (a.CompareTo(b) > 0)) { id += "node" + ModelHelper.ReduceId(b.Id) + ModelHelper.ReduceId(a.Id); } else { id += "node" + ModelHelper.ReduceId(a.Id) + ModelHelper.ReduceId(b.Id); } //TODO: How to handle changing parents for strict nodes? //id += "node" + ModelHelper.ReduceId(parent.Id) + ModelHelper.ReduceId(a.Id) + ModelHelper.ReduceId(b.Id); if (!parent.Root.IsStrict) { id += Guid.NewGuid(); } id += @""""; return(ModelHelper.ReduceId(id)); }
public static Task <BaseObjectType> GetTypeAsync(this IBaseObject baseObject) => AltVAsync.Schedule(() => baseObject.Type);
public void TestInitialize() { scope = AutofacContainer.GetLifetimeScope(); single = scope.Resolve <IBaseObject>(); }
public static Task SetMetaDataAsync(this IBaseObject baseObject, string key, object value) { var mValue = MValue.CreateFromObject(value); return(AltVAsync.Schedule(() => baseObject.SetMetaData(key, mValue))); }
public void Update(IBaseObject baseObject) { OccassionDao.Update(baseObject); }
public static Task <T> GetMetaDataAsync <T>(this IBaseObject baseObject, string key) => AltVAsync.Schedule(() => {
public void Add(IBaseObject item) { _elements[item.Id] = item; }
public TreeElement(IBaseObject linkedTo) { InitializeComponent(); App.DarkmodeUrMenus(globalButton.ContextMenu.Items); constant.Source = App.MakeDarkTheme(constant.Source as BitmapSource); (deleteButton.Content as Image).Source = App.MakeDarkTheme((deleteButton.Content as Image).Source as BitmapSource); (editButton.Content as Image).Source = App.MakeDarkTheme((editButton.Content as Image).Source as BitmapSource); Title.Foreground = App.DarkFontColor; Link = linkedTo; constant.Visibility = Visibility.Collapsed; if (linkedTo is Program pr) { deleteButton.Visibility = Visibility.Collapsed; Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.algo))); Title.Text = pr.Name; globalButton.ContextMenu.Items.Remove(globalButton.ContextMenu.Items.GetItemAt(6)); //Remove a separator from contextmenu globalButton.ContextMenu.Items.Remove(globalButton.ContextMenu.Items.GetItemAt(5)); //Remove Cut from contextmenu globalButton.ContextMenu.Items.Remove(globalButton.ContextMenu.Items.GetItemAt(4)); //Remove Copy from contextmenu globalButton.ContextMenu.Items.Remove(globalButton.ContextMenu.Items.GetItemAt(2)); //Remove Delete from contextmenu } else if (linkedTo is Function fct) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.function))); Title.Text = fct.Name; } else if (linkedTo is ILANET.Module mod) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.module))); Title.Text = mod.Name; } else if (linkedTo is VariableDeclaration vd) { if (vd.CreatedVariable.Constant) { Title.Foreground = new SolidColorBrush(Colors.LightBlue); constant.Visibility = Visibility.Visible; } editButton.Visibility = Visibility.Collapsed; if (vd.CreatedVariable.Type is IGenericType gt) { if (gt == GenericType.String) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._string))); } else if (gt == GenericType.Int) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.int_var))); } else if (gt == GenericType.Char) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._char))); } else if (gt == GenericType.Bool) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._bool))); } else if (gt == GenericType.Float) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.float_var))); } } else { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.custom_var))); } Title.Text = vd.CreatedVariable.Name; } else if (linkedTo is TypeDeclaration td) { editButton.Visibility = Visibility.Collapsed; if (td.CreatedType is StructType) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._struct))); } else if (td.CreatedType is TableType) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.table))); } else if (td.CreatedType is EnumType) { Icon.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._enum))); } Title.Text = td.CreatedType.Name; } globalButton.ContextMenu.Items.Remove(globalButton.ContextMenu.Items.GetItemAt(1)); //Remove Add from contextmenu globalButton.ContextMenu.Items.Remove(globalButton.ContextMenu.Items.GetItemAt(globalButton.ContextMenu.Items.Count - 4)); //Remove Paste from contextmenu }
public IResult PerformCommand(IMobileObject performer, ICommand command) { IResult result = base.PerfomCommand(performer, command); if (result != null) { return(result); } if (command.Parameters.Count == 0) { return(new Result("While you ponder what to open you let you mouth hang open. Hey you did open something!", true)); } IParameter parameter = command.Parameters[0]; IBaseObject foundItem = GlobalReference.GlobalValues.FindObjects.FindObjectOnPersonOrInRoom(performer, parameter.ParameterValue, parameter.ParameterNumber, true, true, false, false, true); if (foundItem != null) { if (foundItem is IDoor door) { result = ProcessDoor(performer, door); if (result != null) { return(result); } if (door.Linked) { IRoom otherRoom = GlobalReference.GlobalValues.World.Zones[door.LinkedRoomId.Zone].Rooms[door.LinkedRoomId.Id]; IDoor otherDoor = null; switch (door.LinkedRoomDirection) { case Direction.North: otherDoor = otherRoom.North.Door; break; case Direction.East: otherDoor = otherRoom.East.Door; break; case Direction.South: otherDoor = otherRoom.South.Door; break; case Direction.West: otherDoor = otherRoom.West.Door; break; case Direction.Up: otherDoor = otherRoom.Up.Door; break; case Direction.Down: otherDoor = otherRoom.Down.Door; break; } if (otherDoor != null) { otherDoor.Locked = false; otherDoor.Opened = true; } } return(door.Open(performer)); } else { if (foundItem is IOpenable openable) { return(openable.Open(performer)); } } return(new Result("You found what you were looking for but could not figure out how to open it.", true)); } else { return(new Result("You were unable to find that what you were looking for.", true)); } }
/// <summary> /// Sets or replaces element in specified position. /// </summary> /// <param name="item"> /// Element to set. /// </param> /// <param name="index"> /// Position in sequence. /// </param> public abstract void Set(IBaseObject item, int index);