public static int GetElementNumberContainingNodes(IScheme scheme, int startNodeNumber, int endNodeNumber) { IElement currentElement = scheme.ListIElement .Where(element => (element.IntNodeLeft == startNodeNumber && element.IntNodeRight == endNodeNumber)) .FirstOrDefault(); return(currentElement.IntNumber > 0 ? currentElement.IntNumber : -1); }
private void ClearFeatureScheme(TFeatureBasedMapData mapData, IScheme scheme) { if (mapData.Theme != null) { scheme.ClearCategories(); scheme.AddCategory(CreateDefaultCategory(mapData)); } }
public static IResult GetApproximatedResult(IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double x) { double leftValue; leftValue = GetResult(scheme, model, elementBoundaryDisplacements, x); return(new Result(true, leftValue, leftValue)); }
public Model(IScheme scheme) { this.scheme = scheme; this.LW = 2; this.LQ = 2; ln = scheme.Nodes.Count(); le = scheme.Elements.Count(); }
/// <summary> /// Class constructor method. /// </summary> /// <param name="scheme"></param> public Model(IScheme scheme) { AbstractIScheme = scheme; IntNodesPerElement = 2; IntDOFPerNode = 2; IntModelNodes = scheme.ListINode.Count(); IntModelElements = scheme.ListIElement.Count(); // Debug.WriteLine($"\nModel class constructor: IntModelNodes={IntModelNodes}, IntModelElements={IntModelElements}"); }
/*** Private methods ***************************************************************************************************/ private static double GetAlongTheMemberResult(IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double x, int startNodeNumber, int elementNumber) { IBeamProperty beamProperty = model.Beam.Properties.Where(beam => beam.Number == elementNumber).FirstOrDefault(); double L = beamProperty.Lb; double s = ResultHelper.GetScalingParameter(scheme, x, startNodeNumber, L); double[,] currentShapeFunctionsVector = GetShapeFunctionsVector(s, L); double[,] result = MatrixTransformation.Multiply(currentShapeFunctionsVector, elementBoundaryDisplacements[elementNumber]); return(result[0, 0]); }
/// <summary> /// Search iScheme.ListINode to determine if any INode positions in list match parameter position. /// Return INode number if match was found and is > 0, otherwise return -1. /// </summary> /// <param name="iScheme">Scheme that contains list of INodes used in beam.</param> /// <param name="doublePosition">Position on beam from left to right.</param> /// <returns></returns> public static int ExactResultExists(IScheme iScheme, double doublePosition) { INode iNodeMatch = iScheme.ListINode.Where(iNode => iNode.DoubleNodePosition == doublePosition).FirstOrDefault(); if (iNodeMatch != null) { return(iNodeMatch.IntNumber > 0 ? iNodeMatch.IntNumber : -1); // Is condition true ? yes : no } return(-1); }
/// <summary> /// Установить схему /// </summary> private void SetScheme() { IScheme scheme = _schemes.GetScheme(SelectedScheme); foreach (PlayBoxViewModel plBoxVM in _playBoxVMs) { ILocationPosition locPos = scheme.GetLocation(plBoxVM.LocNumber); plBoxVM.SetLocPos(locPos); } }
public Upgrade(IScheme scheme, IncomeType type) { if (scheme == null) { Console.WriteLine("WTF??"); } _scheme = scheme; IncomeType = type; Price = _scheme.StartPrice; }
private static void EditMonsterScheme(IScheme scheme) { Console.WriteLine($"Name Ru: {scheme.Name?.Ru}"); var nameRu = Console.ReadLine(); if (string.IsNullOrWhiteSpace(nameRu)) { Console.Write("[Old value]"); Console.WriteLine(); } }
public static int ExactResultExists(IScheme scheme, double x) { INode currentNode = scheme.Nodes.Where(node => node.X == x).FirstOrDefault(); if (currentNode != null) { return(currentNode.Number > 0 ? currentNode.Number : -1); } return(-1); }
public static IResult GetExactResult(IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double x) { double leftValue; leftValue = GetResult(scheme, model, elementBoundaryDisplacements, x - 0.001); double rightValue; rightValue = GetResult(scheme, model, elementBoundaryDisplacements, x + 0.001); return(new Result(false, leftValue, rightValue)); }
/*** Private methods ***************************************************************************************************/ private static double CalculateResultShear(IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double doublePosition) { ResultHelper.GetBoundaryNodes(scheme, model, doublePosition, out int startNodeNumber, out int endNodeNumber); int elementNumber = -1; if (startNodeNumber >= 1 && endNodeNumber >= 1) { elementNumber = ResultHelper.GetElementNumberContainingNodes(scheme, startNodeNumber, endNodeNumber); } if (elementNumber >= 1) { return(GetAlongTheMemberResult(model, elementBoundaryDisplacements, elementNumber)); } return(0); }
public static double GetApproximatedResult(IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double x) { ResultHelper.GetBoundaryNodes(scheme, model, x, out int startNodeNumber, out int endNodeNumber); int elementNumber = -1; if (startNodeNumber >= 1 && endNodeNumber >= 1) { elementNumber = ResultHelper.GetElementNumberContainingNodes(scheme, startNodeNumber, endNodeNumber); } if (elementNumber >= 1) { return(GetAlongTheMemberResult(scheme, model, elementBoundaryDisplacements, x, startNodeNumber, elementNumber)); } return(0); }
public static void GetBoundaryNodes(IScheme scheme, IModel model, double x, out int startNodeNumber, out int endNodeNumber) { startNodeNumber = -1; endNodeNumber = -1; for (int i = 0; i < model.ln; i++) { INode currentNode = scheme.Nodes[i]; if (currentNode.X > x) { endNodeNumber = currentNode.Number; startNodeNumber = currentNode.Number - 1; break; } } }
public static void GetBoundaryNodes(IScheme scheme, IModel model, double x, out int startNodeNumber, out int endNodeNumber) { startNodeNumber = -1; endNodeNumber = -1; for (int i = 0; i < model.IntModelNodes; i++) { INode currentNode = scheme.ListINode[i]; if (currentNode.DoubleNodePosition > x) { endNodeNumber = currentNode.IntNumber; startNodeNumber = currentNode.IntNumber - 1; break; } } }
private static void CheckConversion(string html, string expected, IScheme scheme = null) { Converter converter; if (scheme == null) { converter = new Converter(); } else { converter = new Converter(scheme); } var result = converter.Convert(html); Assert.That(result, Is.EqualTo(expected)); }
public static TParentType CreateTypeObjectFromParent <TParentType, TField>(IScheme <TField> scheme) where TField : IField { try { var schemeKey = string.Join(";", scheme.Keys.OrderBy(x => x)); var instanceType = _proxyTypes.GetOrAdd(schemeKey, (key) => CreateTypeFromParent <TParentType, TField>(scheme)); if (instanceType != null) { var obj = Activator.CreateInstance(instanceType, new object[] { scheme }); return((TParentType)obj); } } catch (Exception ex) { Debug.WriteLine("CreateTypeObjectFromParent<{0}>: {1}", typeof(TParentType).Name, ex.Message); } return(default(TParentType)); }
/*** Public methods ****************************************************************************************************/ /// <summary> /// Get shear result at doublePosition. /// </summary> /// <param name="boolIsNode">If true then return then return shear values left and right of doublePosition, otherwise return shear value at doublePosition.</param> /// <param name="scheme"></param> /// <param name="model"></param> /// <param name="elementBoundaryDisplacements"></param> /// <param name="doublePosition">Position is distance from left end of beam.</param> /// <returns></returns> public static ValueResult GetResultShear(bool boolIsNode, IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double doublePosition) { double doubleValueLeft; double doubleValueRight; if (boolIsNode) { doubleValueLeft = CalculateResultShear(scheme, model, elementBoundaryDisplacements, doublePosition - PostProcessor.doubleOffsetDistance); doubleValueRight = CalculateResultShear(scheme, model, elementBoundaryDisplacements, doublePosition + PostProcessor.doubleOffsetDistance); } else { doubleValueLeft = CalculateResultShear(scheme, model, elementBoundaryDisplacements, doublePosition); doubleValueRight = doubleValueLeft; } //Debug.WriteLine($"ShearForce.GetResultShear(): boolIsNode={boolIsNode}, doublePosition={doublePosition}, doubleValueLeft={doubleValueLeft}, doubleValueRight={doubleValueRight}"); return(new ValueResult(boolIsNode, doubleValueLeft, doubleValueRight)); }
public void MakeFitnessScheme() { workoutBuilder.ScheduleWorkoutDay("Monday"); workoutBuilder.AddBicycleManoeuvre(); workoutBuilder.AddLunge(); workoutBuilder.AddPullUp(); workoutBuilder.ScheduleWorkoutDay("Wednesday"); workoutBuilder.AddPullUp(); workoutBuilder.AddLunge(); workoutBuilder.AddSwissBallHamsteringCurl(); workoutBuilder.AddTricepsDips(); workoutBuilder.ScheduleWorkoutDay("Friday"); workoutBuilder.AddPushUp(); workoutBuilder.AddPushUp(); workoutBuilder.AddSideBridge(); workoutBuilder.AddSquat(); FitnessScheme = workoutBuilder.GetScheme(); }
private static double GetAlongTheMemberResult(IScheme scheme, IModel model, Dictionary <int, double[, ]> elementBoundaryDisplacements, double x, int startNodeNumber, int endNodeNumber, int elementNumber) { IBeamProperty beamProperty = model.Beam.Properties.Where(beam => beam.Number == elementNumber).FirstOrDefault(); double L; L = beamProperty.L; double[,] currentShapeFunctionsVector = GetShapeFunctionsVector(L); double[,] result; result = MatrixTransformation.Multiply <double, double>(currentShapeFunctionsVector, elementBoundaryDisplacements[elementNumber]); double resultFactor; resultFactor = beamProperty.E * beamProperty.Iy / Math.Pow(beamProperty.L, 3); result = MatrixTransformation.Multiply(result, resultFactor); return(result[0, 0]); }
/// <summary> /// Инициализация боксов и расстановка по схеме /// </summary> private void InitPLayBoxVMs() { IScheme scheme = _schemes.GetScheme(SelectedScheme); foreach (ILocationPosition locPos in scheme) { PlayBoxViewModel plBoxVM = new PlayBoxViewModel(locPos); plBoxVM.BoxSelected += PlBoxVM_BoxSelected; plBoxVM.PreRemovalPlayer += PlBoxVM_PreRemovalPlayer; _playBoxVMs.Add(plBoxVM); } if (_players.Count > 0) { foreach (PlayerViewModel plVM in _players) { _playBoxVMs[plVM.CurrentLocNumber - 1].SetPlayer(plVM); } } }
public static double GetScalingParameter(IScheme scheme, double x, int elementNumber, int startNodeNumber, int endNodeNumber, double L) { INode currentStartNode = scheme.Nodes.Where(node => node.Number == startNodeNumber).FirstOrDefault(); return((x - currentStartNode.X) / L); }
BuildScheme( SchemeParametersBase <KasDsaAlgoAttributesFfc> schemeParameters, KdfParameters kdfParameters, MacParameters macParameters, bool backToOriginalState = true ) { IScheme < SchemeParametersBase <KasDsaAlgoAttributesFfc>, KasDsaAlgoAttributesFfc, OtherPartySharedInformation < FfcDomainParameters, FfcKeyPair >, FfcDomainParameters, FfcKeyPair > scheme = null; var dsa = _dsaFfcFactory.GetInstance(_withHashFunction); switch (schemeParameters.KasAlgoAttributes.Scheme) { case FfcScheme.DhHybrid1: scheme = new SchemeFfcDhHybrid1(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman); break; case FfcScheme.Mqv2: scheme = new SchemeFfcMqv2(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withMqv); break; case FfcScheme.DhEphem: scheme = new SchemeFfcDiffieHellmanEphemeral(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman); break; case FfcScheme.DhHybridOneFlow: scheme = new SchemeFfcDhHybridOneFlow(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman); break; case FfcScheme.Mqv1: scheme = new SchemeFfcMqv1(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withMqv); break; case FfcScheme.DhOneFlow: scheme = new SchemeFfcDhOneFlow(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman); break; case FfcScheme.DhStatic: scheme = new SchemeFfcDhStatic(dsa, _withKdfFactory, _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory, _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman); break; default: throw new ArgumentException(nameof(schemeParameters.KasAlgoAttributes.Scheme)); } if (backToOriginalState) { SetWithInjectablesToConstructionState(); } return(scheme); }
public Helper(IScheme scheme) { this.scheme = scheme; }
public static double GetScalingParameter(IScheme scheme, double x, int startNodeNumber, double L) { INode currentStartNode = scheme.ListINode.Where(node => node.IntNumber == startNodeNumber).FirstOrDefault(); return((x - currentStartNode.DoubleNodePosition) / L); }
/// <summary> /// Create a converter with a custom conversion scheme /// </summary> /// <param name="scheme">Conversion scheme to control conversion</param> public Converter(IScheme scheme) { _scheme = scheme; _replacers = scheme.Replacers(); }
public void CreateNewWorkoutScheme() => fitnessScheme = new FitnessScheme();
public Kas(IScheme scheme) { Scheme = scheme; }
public static Type CreateTypeFromParent <TParentType, TField>(IScheme <TField> scheme) where TField : IField { try { var parentType = typeof(TParentType); var instanceType = parentType; var aName = new AssemblyName("DynamicAssemblyExample_" + Guid.NewGuid().ToString()); var ab = AssemblyBuilder.DefineDynamicAssembly(aName, AssemblyBuilderAccess.Run); var mb = ab.DefineDynamicModule(aName.Name); var tb = mb.DefineType("CustomFieldsProxy_" + Guid.NewGuid().ToString(), TypeAttributes.Public, parentType); var ProxyGetValue_ = parentType.GetMethod(nameof(IProxyGetSet.ProxyGetValue), BindingFlags.Instance | BindingFlags.NonPublic); var ProxySetValue_ = parentType.GetMethod(nameof(IProxyGetSet.ProxySetValue), BindingFlags.Instance | BindingFlags.NonPublic); if (ProxyGetValue_ != null && ProxySetValue_ != null) { //Создаем пронумерованные свойства foreach (var field in scheme) { var name = $"fieldValue_{field.Value.IdField}"; var returnType = typeof(object); returnType = field.Value.GetValueType(); if (field.Value.IsMultipleValues) { returnType = typeof(IEnumerable <>).MakeGenericType(returnType); } if (!field.Value.IsValueRequired && returnType.IsValueType) { returnType = typeof(Nullable <>).MakeGenericType(returnType); } var ProxyGetValue = ProxyGetValue_.MakeGenericMethod(returnType); var ProxySetValue = ProxySetValue_.MakeGenericMethod(returnType); var property = tb.DefineProperty(name, PropertyAttributes.None, returnType, null); /* * Атрибуты * */ if (field.Value.IsValueRequired) { var requiredAttribute = typeof(MetadataAndValues.RequiredAttributeCustom).GetConstructor(Type.EmptyTypes); property.SetCustomAttribute(new CustomAttributeBuilder(requiredAttribute, new object[] { })); } switch (field.Value.IdValueType) { case FieldValueType.Email: property.SetCustomAttribute(new CustomAttributeBuilder(typeof(EmailAddressAttribute).GetConstructor(Type.EmptyTypes), new object[] { })); break; case FieldValueType.Phone: property.SetCustomAttribute(new CustomAttributeBuilder(typeof(PhoneAttribute).GetConstructor(Type.EmptyTypes), new object[] { })); break; case FieldValueType.URL: property.SetCustomAttribute(new CustomAttributeBuilder(typeof(UrlAttribute).GetConstructor(Type.EmptyTypes), new object[] { })); break; } var displayAttribute = typeof(DisplayAttribute).GetConstructor(Type.EmptyTypes); var displayAttributePropName = typeof(DisplayAttribute).GetProperty(nameof(DisplayAttribute.Name)); property.SetCustomAttribute(new CustomAttributeBuilder(displayAttribute, new object[] { }, new PropertyInfo[] { displayAttributePropName }, new object[] { field.Value.GetDisplayName() })); var additionalAttributes = field.Value.FieldType.GetCustomAttributeBuildersForModel(field.Value); if (additionalAttributes != null) { foreach (var attribute in additionalAttributes) { if (attribute != null) { property.SetCustomAttribute(attribute); } } } /* * Методы GET-SET * */ var getSetAttr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName; MethodBuilder getter = tb.DefineMethod("get_" + name, getSetAttr, returnType, Type.EmptyTypes); var getIL = getter.GetILGenerator(); getIL.Emit(OpCodes.Ldarg_0); getIL.Emit(OpCodes.Ldc_I4, field.Value.IdField); getIL.Emit(OpCodes.Call, ProxyGetValue); getIL.Emit(OpCodes.Ret); var setter = tb.DefineMethod("set_" + name, getSetAttr, null, new Type[] { returnType }); var setIL = setter.GetILGenerator(); setIL.Emit(OpCodes.Ldarg_0); setIL.Emit(OpCodes.Ldc_I4, field.Value.IdField); setIL.Emit(OpCodes.Ldarg_1); setIL.Emit(OpCodes.Call, ProxySetValue); setIL.Emit(OpCodes.Ret); property.SetGetMethod(getter); property.SetSetMethod(setter); } //Создаем именованные свойства foreach (var field in scheme) { if (!string.IsNullOrEmpty(field.Value.alias)) { var name = field.Value.alias; var returnType = typeof(object); returnType = field.Value.GetValueType(); if (field.Value.IsMultipleValues) { returnType = typeof(IEnumerable <>).MakeGenericType(returnType); } var ProxyGetValue = ProxyGetValue_.MakeGenericMethod(returnType); var ProxySetValue = ProxySetValue_.MakeGenericMethod(returnType); var property = tb.DefineProperty(name, PropertyAttributes.None, returnType, null); /* * Атрибуты * */ if (field.Value.IsValueRequired) { var requiredAttribute = typeof(MetadataAndValues.RequiredAttributeCustom).GetConstructor(Type.EmptyTypes); property.SetCustomAttribute(new CustomAttributeBuilder(requiredAttribute, new object[] { })); } var displayAttribute = typeof(DisplayAttribute).GetConstructor(Type.EmptyTypes); var displayAttributePropName = typeof(DisplayAttribute).GetProperty(nameof(DisplayAttribute.Name)); property.SetCustomAttribute(new CustomAttributeBuilder(displayAttribute, new object[] { }, new PropertyInfo[] { displayAttributePropName }, new object[] { field.Value.GetDisplayName() })); //var additionalAttributes = field.Value.type.GetCustomAttributeBuildersForModel(field.Value); //if (additionalAttributes != null) // foreach (var attribute in additionalAttributes) // if (attribute != null) // property.SetCustomAttribute(attribute); /* * Методы GET-SET * */ var getSetAttr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName; MethodBuilder getter = tb.DefineMethod("get_" + name, getSetAttr, returnType, Type.EmptyTypes); var getIL = getter.GetILGenerator(); getIL.Emit(OpCodes.Ldarg_0); getIL.Emit(OpCodes.Ldc_I4, field.Value.IdField); getIL.Emit(OpCodes.Call, ProxyGetValue); getIL.Emit(OpCodes.Ret); var setter = tb.DefineMethod("set_" + name, getSetAttr, null, new Type[] { returnType }); var setIL = setter.GetILGenerator(); setIL.Emit(OpCodes.Ldarg_0); setIL.Emit(OpCodes.Ldc_I4, field.Value.IdField); setIL.Emit(OpCodes.Ldarg_1); setIL.Emit(OpCodes.Call, ProxySetValue); setIL.Emit(OpCodes.Ret); property.SetGetMethod(getter); property.SetSetMethod(setter); } } CreatePassThroughConstructors(tb, parentType); var typeddd = tb.CreateTypeInfo(); instanceType = typeddd; } return(instanceType); } catch (Exception ex) { Debug.WriteLine("CreateTypeFromParent<{0}>: {1}", typeof(TParentType).Name, ex.Message); } return(null); }