public IConfigurationSetting ReadSetting() { var setting = new ConfigurationSetting(); while (!IsEndOfStream()) { var line = ReadLine(); if (!string.IsNullOrWhiteSpace(line)) { if (line.TrimStart()[0] == '#') { ReadAttributeValue(line.Substring(1), setting); } else { // Expression can be multi-line so read all lines up to the next comment int startingLineNumber = _lineNumber; var text = line + ReadRemainingExpressionText(); if (ParseSetting(text, startingLineNumber, setting)) { if (IsEnvNew(setting)) { // Skip, as it's not a real setting, it's the creation of the environment setting = new ConfigurationSetting(); continue; } return setting; } break; } } } return null; }
/// <summary> /// Deserializes the specified configuration in a <see cref="Procedure"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); if (parameterClass!=null) { } else { if (parameterMap == null) { parameterMap = modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP); } } return new Procedure( id, parameterClass, parameterMap, resultClass, resultsMap, listClass, listClassFactory, cacheModel, remapResults, string.Empty, sqlSource, preserveWhitespace); }
public static IConfigurationSetting Create(IPEndPoint endPoint) { var setting = new ConfigurationSetting(); var uri = GetUri(); setting.Endpoint = endPoint; setting.Port = uri.Port; setting.Origin = GetOrigins(); setting.Location = uri.Host; setting.Scheme = uri.Scheme; setting.Uri = uri; setting.BufferSize = 8192; return setting; }
/// <summary> /// Deserializes the specified configuration in a <see cref="Update"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); return new Update( id, parameterClass, parameterMap, remapResults, extendsName, sqlSource, preserveWhitespace); }
private SelectKey BuildSelectKey(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { SelectKey selectKey = null; ConfigurationCollection selectKeys = config.Children.Find(ConfigConstants.ELEMENT_SELECTKEY); if (selectKeys.Count > 0) { IConfiguration selectKeyConfig = selectKeys[0]; BaseStatementDeSerializer selectKeyDeSerializer = new SelectKeyDeSerializer(); selectKey = (SelectKey)selectKeyDeSerializer.Deserialize(modelStore, selectKeyConfig, configurationSetting); } return selectKey; }
/// <summary> /// Deserializes the specified configuration in a <see cref="Select"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); string propertyName = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_PROPERTY); SelectKeyType selectKeyType = ReadSelectKeyType(ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_TYPE)); return new SelectKey( config.Parent.Id + ConfigConstants.DOT + "SelectKey", propertyName, resultClass, resultsMap, selectKeyType, sqlSource, preserveWhitespace); }
/// <summary> /// Deserializes the specified configuration in a <see cref="Insert"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); SelectKey selectKey = BuildSelectKey(modelStore, config, configurationSetting); return new Insert( id, parameterClass, parameterMap, resultClass, resultsMap, null, null, cacheModel, remapResults, extendsName, selectKey, sqlSource, preserveWhitespace ); }
/// <summary> /// Deserializes the specified configuration in a Statement object. /// </summary> /// <param name="modelStore"></param> /// <param name="config">The config.</param> /// <param name="configurationSetting">Default settings.</param> /// <returns></returns> protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE); id = configurationSetting.UseStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id; cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL); extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS); listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS); parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS); parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP); resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS); resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP); remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false); sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE); preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace); // Gets the results Map if (resultMapName.Length > 0) { string[] ids = resultMapName.Split(','); for (int i = 0; i < ids.Length; i++) { string name = ApplyNamespace(nameSpace, ids[i].Trim()); resultsMap.Add(modelStore.GetResultMap(name)); } } // Gets the results class if (resultClassName.Length > 0) { string[] classNames = resultClassName.Split(','); for (int i = 0; i < classNames.Length; i++) { resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim()); IFactory resultClassFactory = null; if (Type.GetTypeCode(resultClass) == TypeCode.Object && (resultClass.IsValueType == false) && resultClass != typeof(DataRow)) { resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes); } IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass); bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass); IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType); resultsMap.Add(autoMap); } } // Gets the ParameterMap if (parameterMapName.Length > 0) { parameterMap = modelStore.GetParameterMap(parameterMapName); } // Gets the ParameterClass if (parameterClassName.Length > 0) { parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName); } // Gets the listClass if (listClassName.Length > 0) { listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName); listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes); } // Gets the CacheModel if (cacheModelName.Length > 0) { cacheModel = modelStore.GetCacheModel(cacheModelName); } // Gets the SqlSource if (sqlSourceClassName.Length > 0) { Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName); IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes); sqlSource = (ISqlSource)factory.CreateInstance(null); } }
private bool IsEnvNew(ConfigurationSetting s) { return s.Name == "settings" && s.Value == "as.environment(list())" && s.ValueType == ConfigurationSettingValueType.Expression; }
/// <summary> /// Deserializes the specified configuration in a Statement object. /// </summary> /// <param name="modelStore"></param> /// <param name="config">The config.</param> /// <param name="configurationSetting">Default settings.</param> /// <returns></returns> protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE); id = configurationSetting.UseStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id; cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL); extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS); listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS); parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS); parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP); resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS); resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP); remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false); sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE); preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, configurationSetting.PreserveWhitespace); // Gets the results Map //resultMaps的属性值会有多个返回值的情况 并且以","分割 if (resultMapName.Length > 0) { string[] ids = resultMapName.Split(','); for (int i = 0; i < ids.Length; i++) { string name = ApplyNamespace(nameSpace, ids[i].Trim()); resultsMap.Add(modelStore.GetResultMap(name)); } } // Gets the results class //resultClass的属性值也会有多个返回值的情况 并且以","分割 if (resultClassName.Length > 0) { string[] classNames = resultClassName.Split(','); for (int i = 0; i < classNames.Length; i++) { resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim()); IFactory resultClassFactory = null; if (Type.GetTypeCode(resultClass) == TypeCode.Object && (resultClass.IsValueType == false) && resultClass != typeof(DataRow)) { //用于创建类对象的函数 resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes); } IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass); bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass); IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType); resultsMap.Add(autoMap); } } // Gets the ParameterMap //去DefaultModelBuilder中的parameterMaps字典中获取对应的参数类 if (parameterMapName.Length > 0) { parameterMap = modelStore.GetParameterMap(parameterMapName); } // Gets the ParameterClass //去TypeHandlerFactory中的typeAlias字典中获取其对应的类别名类 if (parameterClassName.Length > 0) { parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName); } // Gets the listClass if (listClassName.Length > 0) { //去TypeHandlerFactory中的typeAlias字典中获取其对应的类别名类 listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName); //创建对应的对象创建工厂类 listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes); } // Gets the CacheModel if (cacheModelName.Length > 0) { //DefaultModelBuilder中的cacheModels字典中获取对应的缓存类 cacheModel = modelStore.GetCacheModel(cacheModelName); } // Gets the SqlSource if (sqlSourceClassName.Length > 0) { //获取SqlSource属性值对应的类 Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName); //获取创建得到类的工厂 IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes); //调用构造函数 初始化该类 sqlSource = (ISqlSource)factory.CreateInstance(null); } }
/// <summary> /// Updates the specified config. /// </summary> /// <param name="config">The config.</param> public void Update(ConfigurationSetting config) { Update(config, true); }
private SelectKey BuildSelectKey(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { SelectKey selectKey = null; ConfigurationCollection selectKeys = config.Children.Find(ConfigConstants.ELEMENT_SELECTKEY); if (selectKeys.Count > 0) { IConfiguration selectKeyConfig = selectKeys[0]; BaseStatementDeSerializer selectKeyDeSerializer = new SelectKeyDeSerializer(); selectKey = (SelectKey)selectKeyDeSerializer.Deserialize(modelStore, selectKeyConfig, configurationSetting); } return(selectKey); }
public ServerChannel(IContainer container, IChannelPipeline pipeline, IByteBuffer buffer, IFramer framer, ConfigurationSetting setting) : base(buffer, framer) { Ensure.IsNotNull(container); Ensure.IsNotNull(pipeline); Ensure.IsNotNull(buffer); Ensure.IsNotNull(framer); SendingBufferSize = setting.SocketSendBufferSize; ReceivingBufferSize = setting.SocketReceiveBufferSize; _container = container; _setting = setting; this.pipeline = pipeline; _channelPipelineFactory?.Invoke(pipeline); SetSocket(SocketUtils.CreateSocket()); }
public void ShowSetting(ConfigurationSetting config) { configurationSetting = config; ShowSource.isOn = config.ShowSource == 1; ShowInput.isOn = config.ShowInput == 1; SkipOnDrop.isOn = config.SkipOnDrop == 1; RepeatPlayback.isOn = config.RepeatPlayback == 1; MirrorUseCamera.isOn = config.MirrorUseCamera == 1; ifSourceCutScale.text = config.SourceCutScale.ToString("0.00"); ifSourceCutX.text = config.SourceCutX.ToString("0.00"); ifSourceCutY.text = config.SourceCutY.ToString("0.00"); ShowBackground.isOn = config.ShowBackground == 1; ifBackgroundFile.text = config.BackgroundFile; ifBackgroundScale.text = config.BackgroundScale.ToString("0.00"); ifBackgroundR.text = config.BackgroundR.ToString("0"); ifBackgroundG.text = config.BackgroundG.ToString("0"); ifBackgroundB.text = config.BackgroundB.ToString("0"); ifLowPassFilter.text = config.LowPassFilter.ToString("0.00"); ifNOrderLPF.text = config.NOrderLPF.ToString(); //ifBWBuffer.text = config.BWBuffer.ToString(); //ifBWCutoff.text = config.BWCutoff.ToString("0.00"); ifRangePathFilterBuffer.text = config.RangePathFilterBuffer03.ToString("0"); ifFIROrderN.text = config.FIROrderN03.ToString("0"); ifFIRFromHz.text = config.FIRFromHz.ToString("0.00"); ifFIRToHz.text = config.FIRToHz.ToString("0.00"); ifForwardThreshold.text = config.ForwardThreshold.ToString("0.00"); ifBackwardThreshold.text = config.BackwardThreshold.ToString("0.00"); LockFoot.isOn = config.LockFoot == 1; LockLegs.isOn = config.LockLegs == 1; LockHand.isOn = config.LockHand == 1; ElbowAxisTop.isOn = config.ElbowAxisTop == 1; //ifHeightRatioThreshold.text = config.HeightRatioThreshold.ToString("0.00"); trainedModel.value = config.TrainedModel; /* * ifShoulderRattlingCheckFrame.text = config.ShoulderRattlingCheckFrame.ToString(); * ifThighRattlingCheckFrame.text = config.ThighRattlingCheckFrame.ToString(); * ifFootRattlingCheckFrame.text = config.FootRattlingCheckFrame.ToString(); * ifArmRattlingCheckFrame.text = config.ArmRattlingCheckFrame.ToString(); * ifShinThreshold.text = config.ShinThreshold.ToString("0.00"); * ifShinSmooth.text = config.ShinSmooth.ToString("0.00"); * ifShinRatio.text = config.ShinRatio.ToString("0.00"); * ifArmThreshold.text = config.ArmThreshold.ToString("0.00"); * ifArmSmooth.text = config.ArmSmooth.ToString("0.00"); * ifArmRatio.text = config.ArmRatio.ToString("0.00"); * ifOtherThreshold.text = config.OtherThreshold.ToString("0.00"); * ifOtherSmooth.text = config.OtherSmooth.ToString("0.00"); * ifOtherRatio.text = config.OtherRatio.ToString("0.00"); */ Blender.isOn = config.Blender == 1; EnforceHumanoidBones.isOn = config.EnforceHumanoidBones == 1; Capturing.isOn = config.Capturing == 1; ifCapturingFPS.text = config.CapturingFPS.ToString("0"); CatchUp.isOn = config.CatchUp == 1; UseLipSync.isOn = config.UseLipSync == 1; SetMicList(config.SelectedMic); ifLipSyncSmoothAmount.text = config.LipSyncSmoothAmount.ToString("0"); ifLipSyncSensitivity.text = config.LipSyncSensitivity.ToString("0.00"); UseAutoBlink.isOn = config.UseAutoBlink == 1; ifTimeBlink.text = config.TimeBlink.ToString("0.00"); ifAutoBlinkThreshold.text = config.AutoBlinkThreshold.ToString("0.00"); ifAutoBlinkInterval.text = config.AutoBlinkInterval.ToString("0.00"); ShowRoom.isOn = config.ShowRoom == 1; ifRoomX.text = config.RoomX.ToString("0.00"); ifRoomY.text = config.RoomY.ToString("0.00"); ifRoomZ.text = config.RoomZ.ToString("0.00"); ifRoomRotX.text = config.RoomRotX.ToString("0.00"); ifRoomRotY.text = config.RoomRotY.ToString("0.00"); ifRoomRotZ.text = config.RoomRotZ.ToString("0.00"); ifRoomScaleX.text = config.RoomScaleX.ToString("0.00"); ifRoomScaleY.text = config.RoomScaleY.ToString("0.00"); ifRoomScaleZ.text = config.RoomScaleZ.ToString("0.00"); ReceiveShadow.isOn = config.ReceiveShadow == 1; UseGrounderIK.isOn = config.UseGrounderIK == 1; ifIKPositionWeight.text = config.IKPositionWeight.ToString("0.00"); ifLegPositionWeight.text = config.LegPositionWeight.ToString("0.00"); ifHeightOffset.text = config.HeightOffset.ToString("0.00"); UseUnityCapture.isOn = config.UseUnityCapture == 1; UseVMCProtocol.isOn = config.UseVMCProtocol == 1; ifVMCPIP.text = config.VMCPIP; ifVMCPPort.text = config.VMCPPort.ToString("0");; VMCPRot.isOn = config.VMCPRot == 1; }
public void Put(string id, [FromBody] ConfigurationSetting configSetting) { _configurationSettingRepository.Update(id, configSetting); }
public void SetPredictSetting(ConfigurationSetting config) { if (jointPoints == null) { return; } /* * for (var i = 0; i < PositionIndex.Count.Int(); i++) * { * jointPoints[i].RattlingCheckFrame = 5; * jointPoints[i].VecNow3DMagnitude = 0; * jointPoints[i].Threshold = config.OtherThreshold; * jointPoints[i].Smooth = config.OtherSmooth; * jointPoints[i].Ratio = config.OtherRatio; * } * * jointPoints[PositionIndex.lShldrBend.Int()].RattlingCheckFrame = config.ShoulderRattlingCheckFrame; * jointPoints[PositionIndex.rShldrBend.Int()].RattlingCheckFrame = config.ShoulderRattlingCheckFrame; * jointPoints[PositionIndex.lThighBend.Int()].RattlingCheckFrame = config.ThighRattlingCheckFrame; * jointPoints[PositionIndex.rThighBend.Int()].RattlingCheckFrame = config.ThighRattlingCheckFrame; * jointPoints[PositionIndex.lShin.Int()].RattlingCheckFrame = config.FootRattlingCheckFrame; * jointPoints[PositionIndex.rShin.Int()].RattlingCheckFrame = config.FootRattlingCheckFrame; * jointPoints[PositionIndex.lFoot.Int()].RattlingCheckFrame = config.FootRattlingCheckFrame; * jointPoints[PositionIndex.rFoot.Int()].RattlingCheckFrame = config.FootRattlingCheckFrame; * jointPoints[PositionIndex.lToe.Int()].RattlingCheckFrame = config.FootRattlingCheckFrame; * jointPoints[PositionIndex.rToe.Int()].RattlingCheckFrame = config.FootRattlingCheckFrame; * jointPoints[PositionIndex.lForearmBend.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.lHand.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.lThumb2.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.lMid1.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.rForearmBend.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.rHand.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.rThumb2.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * jointPoints[PositionIndex.rMid1.Int()].RattlingCheckFrame = config.ArmRattlingCheckFrame; * * jointPoints[PositionIndex.lShin.Int()].Threshold = config.ShinThreshold; * jointPoints[PositionIndex.rShin.Int()].Threshold = config.ShinThreshold; * jointPoints[PositionIndex.lShin.Int()].Smooth = config.ShinSmooth; * jointPoints[PositionIndex.rShin.Int()].Smooth = config.ShinSmooth; * jointPoints[PositionIndex.lShin.Int()].Ratio = config.ShinRatio; * jointPoints[PositionIndex.rShin.Int()].Ratio = config.ShinRatio; * * jointPoints[PositionIndex.lHand.Int()].Threshold = config.ArmThreshold; * jointPoints[PositionIndex.lThumb2.Int()].Threshold = config.ArmThreshold; * jointPoints[PositionIndex.lMid1.Int()].Threshold = config.ArmThreshold; * jointPoints[PositionIndex.rHand.Int()].Threshold = config.ArmThreshold; * jointPoints[PositionIndex.rThumb2.Int()].Threshold = config.ArmThreshold; * jointPoints[PositionIndex.rMid1.Int()].Threshold = config.ArmThreshold; * * jointPoints[PositionIndex.lHand.Int()].Smooth = config.ArmSmooth; * jointPoints[PositionIndex.lThumb2.Int()].Smooth = config.ArmSmooth; * jointPoints[PositionIndex.lMid1.Int()].Smooth = config.ArmSmooth; * jointPoints[PositionIndex.rHand.Int()].Smooth = config.ArmSmooth; * jointPoints[PositionIndex.rThumb2.Int()].Smooth = config.ArmSmooth; * jointPoints[PositionIndex.rMid1.Int()].Smooth = config.ArmSmooth; * * jointPoints[PositionIndex.lHand.Int()].Ratio = config.ArmRatio; * jointPoints[PositionIndex.lThumb2.Int()].Ratio = config.ArmRatio; * jointPoints[PositionIndex.lMid1.Int()].Ratio = config.ArmRatio; * jointPoints[PositionIndex.rHand.Int()].Ratio = config.ArmRatio; * jointPoints[PositionIndex.rThumb2.Int()].Ratio = config.ArmRatio; * jointPoints[PositionIndex.rMid1.Int()].Ratio = config.ArmRatio; */ LockFoot = config.LockFoot == 1; LockLegs = config.LockLegs == 1; LockHand = config.LockHand == 1; jointPoints[PositionIndex.lToe.Int()].Lock = LockFoot || LockLegs; jointPoints[PositionIndex.rToe.Int()].Lock = LockFoot || LockLegs; jointPoints[PositionIndex.lFoot.Int()].Lock = LockFoot || LockLegs; jointPoints[PositionIndex.rFoot.Int()].Lock = LockFoot || LockLegs; jointPoints[PositionIndex.lShin.Int()].Lock = LockLegs; jointPoints[PositionIndex.rShin.Int()].Lock = LockLegs; jointPoints[PositionIndex.lHand.Int()].Lock = LockHand; jointPoints[PositionIndex.rHand.Int()].Lock = LockHand; if (config.ElbowAxisTop == 0) { jointPoints[PositionIndex.rForearmBend.Int()].Parent = jointPoints[PositionIndex.rShldrBend.Int()]; jointPoints[PositionIndex.lForearmBend.Int()].Parent = jointPoints[PositionIndex.lShldrBend.Int()]; } else { jointPoints[PositionIndex.rForearmBend.Int()].Parent = null; jointPoints[PositionIndex.lForearmBend.Int()].Parent = null; } }
public void CodeConfigurationMatchesSqlMapConfig() { #region SqlMapConfig.xml /* * <sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > * <settings> * <setting useStatementNamespaces="true"/> * <setting cacheModelsEnabled="false"/> * <setting validateSqlMap="false"/> * <setting useReflectionOptimizer="false"/> * <setting preserveWhitespace="false"/> * </settings> * <providers uri="file://providers.config"/> * <database> * <provider name="SQLite3"/> * <dataSource name="ibatisnet.sqlmap" connectionString="Data Source=ibatisnet.sqlite;Version=3;"/> * </database> * <alias> * <typeAlias alias="Account" type="Apache.Ibatis.DataMapper.Sqlite.Test.Domain.Account, Apache.Ibatis.DataMapper.Sqlite.Test"/> * </alias> * <sqlMaps> * <sqlMap uri="file://../../Maps/Account.xml"/> * </sqlMaps> * </sqlMapConfig> */ #endregion // slightly awkward to creating ConfigurationSetting, then engine, then interpreter ??? ConfigurationSetting settings = new ConfigurationSetting(); settings.UseStatementNamespaces = true; settings.IsCacheModelsEnabled = false; settings.ValidateMapperConfigFile = false; settings.UseReflectionOptimizer = false; settings.PreserveWhitespace = false; var engine = new DefaultConfigurationEngine(settings); CodeConfigurationInterpreter codeConfig = new CodeConfigurationInterpreter(engine.ConfigurationStore); codeConfig.AddDatabase(new SqliteDbProvider(), "Data Source=ibatisnet.sqlite;Version=3;"); codeConfig.AddAlias(typeof(Account), "Account"); codeConfig.AddSqlMap("file://../../Maps/Account.xml", true); engine.RegisterInterpreter(codeConfig); IMapperFactory mapperFactory = engine.BuildMapperFactory(); IDataMapper localDataMapper = ((IDataMapperAccessor)mapperFactory).DataMapper; IConfigurationStore store = engine.ConfigurationStore; IConfigurationStore baseStore = ConfigurationEngine.ConfigurationStore; assertConfiguration(baseStore.Properties, store.Properties); // assertConfiguration(baseStore.Settings, store.Settings); assertConfiguration(baseStore.Databases, store.Databases); assertConfiguration(baseStore.TypeHandlers, store.TypeHandlers); assertConfiguration(baseStore.Alias, store.Alias); assertConfiguration(baseStore.CacheModels, store.CacheModels); assertConfiguration(baseStore.ResultMaps, store.ResultMaps); assertConfiguration(baseStore.Statements, store.Statements); assertConfiguration(baseStore.ParameterMaps, store.ParameterMaps); InitScript(SessionFactory.DataSource, "../../Scripts/account-init.sql"); ICollection items = localDataMapper.QueryForList("Account.GetAllAccounts1", null); Assert.IsTrue(items.Count > 1); items = localDataMapper.QueryForList("Account.GetAllAccounts2", null); Assert.IsTrue(items.Count > 1); }
public void Update(ConfigurationSetting config) => ((IHostSettingsService)this).Update(config);
/// <summary> /// Deserializes the specified configuration in a <see cref="Procedure"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); if (parameterClass != null) { } else { if (parameterMap == null) { parameterMap = modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP); } } return(new Procedure( id, parameterClass, parameterMap, resultClass, resultsMap, listClass, listClassFactory, cacheModel, remapResults, string.Empty, sqlSource, preserveWhitespace)); }
private bool IsEnvNew(ConfigurationSetting s) { return(s.Name == "settings" && s.Value == "as.environment(list())" && s.ValueType == ConfigurationSettingValueType.Expression); }
/// <summary> /// Deserializes the specified configuration in a <see cref="Statement"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); return(new Statement( id, parameterClass, parameterMap, resultClass, resultsMap, listClass, listClassFactory, cacheModel, remapResults, extendsName, sqlSource, preserveWhitespace)); }
public void Update(ConfigurationSetting config, bool clearCache) => ((IHostSettingsService)this).Update(config, clearCache);
/// <summary> /// Deserializes the specified configuration in a Statement object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <returns></returns> public abstract IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting);
public JointPoint[] Init(int inputImageSize, ConfigurationSetting config) { movementScale = 0.01f * 224f / inputImageSize; centerTall = inputImageSize * 0.75f; tall = inputImageSize * 0.75f; prevTall = inputImageSize * 0.75f; jointPoints = new JointPoint[PositionIndex.Count.Int()]; for (var i = 0; i < PositionIndex.Count.Int(); i++) { jointPoints[i] = new JointPoint(); jointPoints[i].Index = (PositionIndex)i; jointPoints[i].Score3D = 1; //jointPoints[i].RattlingCheck = false; //jointPoints[i].VecNow3DMagnitude = 0; jointPoints[i].UpperBody = false; jointPoints[i].Lock = false; jointPoints[i].Error = 0; } anim = ModelObject.GetComponent <Animator>(); jointPoints[PositionIndex.hip.Int()].Transform = transform; // Right Arm jointPoints[PositionIndex.rShldrBend.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightUpperArm); jointPoints[PositionIndex.rForearmBend.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightLowerArm); jointPoints[PositionIndex.rHand.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightHand); jointPoints[PositionIndex.rThumb2.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightThumbIntermediate); jointPoints[PositionIndex.rMid1.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightMiddleProximal); // Left Arm jointPoints[PositionIndex.lShldrBend.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftUpperArm); jointPoints[PositionIndex.lForearmBend.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftLowerArm); jointPoints[PositionIndex.lHand.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftHand); jointPoints[PositionIndex.lThumb2.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftThumbIntermediate); jointPoints[PositionIndex.lMid1.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftMiddleProximal); // Face jointPoints[PositionIndex.lEar.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Head); jointPoints[PositionIndex.lEye.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftEye); jointPoints[PositionIndex.rEar.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Head); jointPoints[PositionIndex.rEye.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightEye); jointPoints[PositionIndex.Nose.Int()].Transform = Nose.transform; // Right Leg jointPoints[PositionIndex.rThighBend.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightUpperLeg); jointPoints[PositionIndex.rShin.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightLowerLeg); jointPoints[PositionIndex.rFoot.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightFoot); jointPoints[PositionIndex.rToe.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.RightToes); // Left Leg jointPoints[PositionIndex.lThighBend.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftUpperLeg); jointPoints[PositionIndex.lShin.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftLowerLeg); jointPoints[PositionIndex.lFoot.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftFoot); jointPoints[PositionIndex.lToe.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.LeftToes); // etc jointPoints[PositionIndex.abdomenUpper.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Spine); jointPoints[PositionIndex.head.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Head); jointPoints[PositionIndex.hip.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Hips); jointPoints[PositionIndex.neck.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Neck); jointPoints[PositionIndex.spine.Int()].Transform = anim.GetBoneTransform(HumanBodyBones.Spine); // UpperBody Settings jointPoints[PositionIndex.hip.Int()].UpperBody = true; // Right Arm jointPoints[PositionIndex.rShldrBend.Int()].UpperBody = true; jointPoints[PositionIndex.rForearmBend.Int()].UpperBody = true; jointPoints[PositionIndex.rHand.Int()].UpperBody = true; jointPoints[PositionIndex.rThumb2.Int()].UpperBody = true; jointPoints[PositionIndex.rMid1.Int()].UpperBody = true; // Left Arm jointPoints[PositionIndex.lShldrBend.Int()].UpperBody = true; jointPoints[PositionIndex.lForearmBend.Int()].UpperBody = true; jointPoints[PositionIndex.lHand.Int()].UpperBody = true; jointPoints[PositionIndex.lThumb2.Int()].UpperBody = true; jointPoints[PositionIndex.lMid1.Int()].UpperBody = true; // Face jointPoints[PositionIndex.lEar.Int()].UpperBody = true; jointPoints[PositionIndex.lEye.Int()].UpperBody = true; jointPoints[PositionIndex.rEar.Int()].UpperBody = true; jointPoints[PositionIndex.rEye.Int()].UpperBody = true; jointPoints[PositionIndex.Nose.Int()].UpperBody = true; // etc jointPoints[PositionIndex.spine.Int()].UpperBody = true; jointPoints[PositionIndex.neck.Int()].UpperBody = true; // Parent and Child Settings // Right Arm jointPoints[PositionIndex.rShldrBend.Int()].Child = jointPoints[PositionIndex.rForearmBend.Int()]; jointPoints[PositionIndex.rForearmBend.Int()].Child = jointPoints[PositionIndex.rHand.Int()]; if (config.ElbowAxisTop == 0) { jointPoints[PositionIndex.rForearmBend.Int()].Parent = jointPoints[PositionIndex.rShldrBend.Int()]; } //jointPoints[PositionIndex.rHand.Int()].Parent = jointPoints[PositionIndex.rForearmBend.Int()]; // Left Arm jointPoints[PositionIndex.lShldrBend.Int()].Child = jointPoints[PositionIndex.lForearmBend.Int()]; jointPoints[PositionIndex.lForearmBend.Int()].Child = jointPoints[PositionIndex.lHand.Int()]; if (config.ElbowAxisTop == 0) { jointPoints[PositionIndex.lForearmBend.Int()].Parent = jointPoints[PositionIndex.lShldrBend.Int()]; } //jointPoints[PositionIndex.lHand.Int()].Parent = jointPoints[PositionIndex.lForearmBend.Int()]; // Fase // Right Leg jointPoints[PositionIndex.rThighBend.Int()].Child = jointPoints[PositionIndex.rShin.Int()]; jointPoints[PositionIndex.rShin.Int()].Child = jointPoints[PositionIndex.rFoot.Int()]; jointPoints[PositionIndex.rFoot.Int()].Child = jointPoints[PositionIndex.rToe.Int()]; jointPoints[PositionIndex.rFoot.Int()].Parent = jointPoints[PositionIndex.rShin.Int()]; // Left Leg jointPoints[PositionIndex.lThighBend.Int()].Child = jointPoints[PositionIndex.lShin.Int()]; jointPoints[PositionIndex.lShin.Int()].Child = jointPoints[PositionIndex.lFoot.Int()]; jointPoints[PositionIndex.lFoot.Int()].Child = jointPoints[PositionIndex.lToe.Int()]; jointPoints[PositionIndex.lFoot.Int()].Parent = jointPoints[PositionIndex.lShin.Int()]; // etc jointPoints[PositionIndex.spine.Int()].Child = jointPoints[PositionIndex.neck.Int()]; jointPoints[PositionIndex.neck.Int()].Child = jointPoints[PositionIndex.head.Int()]; //jointPoints[PositionIndex.head.Int()].Child = jointPoints[PositionIndex.Nose.Int()]; //jointPoints[PositionIndex.hip.Int()].Child = jointPoints[PositionIndex.spine.Int()]; // Line Child Settings // Right Arm AddSkeleton(PositionIndex.rShldrBend, PositionIndex.rForearmBend, true); AddSkeleton(PositionIndex.rForearmBend, PositionIndex.rHand, true); AddSkeleton(PositionIndex.rHand, PositionIndex.rThumb2, true); AddSkeleton(PositionIndex.rHand, PositionIndex.rMid1, true); // Left Arm AddSkeleton(PositionIndex.lShldrBend, PositionIndex.lForearmBend, true); AddSkeleton(PositionIndex.lForearmBend, PositionIndex.lHand, true); AddSkeleton(PositionIndex.lHand, PositionIndex.lThumb2, true); AddSkeleton(PositionIndex.lHand, PositionIndex.lMid1, true); // Face //AddSkeleton(PositionIndex.lEar, PositionIndex.lEye); //AddSkeleton(PositionIndex.lEye, PositionIndex.Nose); //AddSkeleton(PositionIndex.rEar, PositionIndex.rEye); //AddSkeleton(PositionIndex.rEye, PositionIndex.Nose); AddSkeleton(PositionIndex.lEar, PositionIndex.Nose, true); AddSkeleton(PositionIndex.rEar, PositionIndex.Nose, true); // Right Leg AddSkeleton(PositionIndex.rThighBend, PositionIndex.rShin, false); AddSkeleton(PositionIndex.rShin, PositionIndex.rFoot, false); AddSkeleton(PositionIndex.rFoot, PositionIndex.rToe, false); // Left Leg AddSkeleton(PositionIndex.lThighBend, PositionIndex.lShin, false); AddSkeleton(PositionIndex.lShin, PositionIndex.lFoot, false); AddSkeleton(PositionIndex.lFoot, PositionIndex.lToe, false); // etc AddSkeleton(PositionIndex.spine, PositionIndex.neck, true); AddSkeleton(PositionIndex.neck, PositionIndex.head, true); AddSkeleton(PositionIndex.head, PositionIndex.Nose, true); AddSkeleton(PositionIndex.neck, PositionIndex.rShldrBend, true); AddSkeleton(PositionIndex.neck, PositionIndex.lShldrBend, true); AddSkeleton(PositionIndex.rThighBend, PositionIndex.rShldrBend, true); AddSkeleton(PositionIndex.lThighBend, PositionIndex.lShldrBend, true); AddSkeleton(PositionIndex.rShldrBend, PositionIndex.abdomenUpper, true); AddSkeleton(PositionIndex.lShldrBend, PositionIndex.abdomenUpper, true); AddSkeleton(PositionIndex.rThighBend, PositionIndex.abdomenUpper, true); AddSkeleton(PositionIndex.lThighBend, PositionIndex.abdomenUpper, true); AddSkeleton(PositionIndex.lThighBend, PositionIndex.rThighBend, true); // Set Inverse var forward = TriangleNormal(jointPoints[PositionIndex.hip.Int()].Transform.position, jointPoints[PositionIndex.lThighBend.Int()].Transform.position, jointPoints[PositionIndex.rThighBend.Int()].Transform.position); foreach (var jointPoint in jointPoints) { if (jointPoint.Transform != null) { jointPoint.InitRotation = jointPoint.Transform.rotation; } if (jointPoint.Child != null) { jointPoint.Inverse = GetInverse(jointPoint, jointPoint.Child, forward); jointPoint.InverseRotation = jointPoint.Inverse * jointPoint.InitRotation; } } var hip = jointPoints[PositionIndex.hip.Int()]; initPosition = transform.position; //initPosition = jointPoints[PositionIndex.hip.Int()].Transform.position; hip.Inverse = Quaternion.Inverse(Quaternion.LookRotation(forward)); hip.InverseRotation = hip.Inverse * hip.InitRotation; // For Head Rotation var head = jointPoints[PositionIndex.head.Int()]; head.InitRotation = jointPoints[PositionIndex.head.Int()].Transform.rotation; var gaze = jointPoints[PositionIndex.Nose.Int()].Transform.position - jointPoints[PositionIndex.head.Int()].Transform.position; head.Inverse = Quaternion.Inverse(Quaternion.LookRotation(gaze)); head.InverseRotation = head.Inverse * head.InitRotation; var lHand = jointPoints[PositionIndex.lHand.Int()]; var lf = TriangleNormal(lHand.Pos3D, jointPoints[PositionIndex.lMid1.Int()].Pos3D, jointPoints[PositionIndex.lThumb2.Int()].Pos3D); lHand.InitRotation = lHand.Transform.rotation; lHand.Inverse = Quaternion.Inverse(Quaternion.LookRotation(jointPoints[PositionIndex.lThumb2.Int()].Transform.position - jointPoints[PositionIndex.lMid1.Int()].Transform.position, lf)); lHand.InverseRotation = lHand.Inverse * lHand.InitRotation; var rHand = jointPoints[PositionIndex.rHand.Int()]; var rf = TriangleNormal(rHand.Pos3D, jointPoints[PositionIndex.rThumb2.Int()].Pos3D, jointPoints[PositionIndex.rMid1.Int()].Pos3D); rHand.InitRotation = jointPoints[PositionIndex.rHand.Int()].Transform.rotation; rHand.Inverse = Quaternion.Inverse(Quaternion.LookRotation(jointPoints[PositionIndex.rThumb2.Int()].Transform.position - jointPoints[PositionIndex.rMid1.Int()].Transform.position, rf)); rHand.InverseRotation = rHand.Inverse * rHand.InitRotation; jointPoints[PositionIndex.hip.Int()].Score3D = 1f; jointPoints[PositionIndex.neck.Int()].Score3D = 1f; jointPoints[PositionIndex.Nose.Int()].Score3D = 1f; jointPoints[PositionIndex.head.Int()].Score3D = 1f; jointPoints[PositionIndex.spine.Int()].Score3D = 1f; /* * jointPoints[PositionIndex.rForearmBend.Int()].RattlingCheck = true; * jointPoints[PositionIndex.rHand.Int()].RattlingCheck = true; * jointPoints[PositionIndex.rThumb2.Int()].RattlingCheck = true; * jointPoints[PositionIndex.rMid1.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lForearmBend.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lHand.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lThumb2.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lMid1.Int()].RattlingCheck = true; * jointPoints[PositionIndex.rShin.Int()].RattlingCheck = true; * jointPoints[PositionIndex.rFoot.Int()].RattlingCheck = true; * jointPoints[PositionIndex.rToe.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lShin.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lFoot.Int()].RattlingCheck = true; * jointPoints[PositionIndex.lToe.Int()].RattlingCheck = true; */ SetPredictSetting(config); defaultCenter = new Vector3(transform.position.x, (jointPoints[PositionIndex.rToe.Int()].Transform.position.y + jointPoints[PositionIndex.lToe.Int()].Transform.position.y) / 2f, transform.position.z); FootIKY = (jointPoints[PositionIndex.rFoot.Int()].Transform.position.y + jointPoints[PositionIndex.lFoot.Int()].Transform.position.y) / 2f + 0.1f; ToeIKY = (jointPoints[PositionIndex.rToe.Int()].Transform.position.y + jointPoints[PositionIndex.lToe.Int()].Transform.position.y) / 2f; return(JointPoints); }
public T GetValue <T>(string key) { ConfigurationSetting found = getConfigurationSetting(key); return((T)Convert.ChangeType(found.Value, typeof(T))); }
public void Post([FromBody] ConfigurationSetting configSetting) { _configurationSettingRepository.Create(configSetting); }
public string GetTypeName(string key) { ConfigurationSetting found = getConfigurationSetting(key); return(found.Type); }
private async Task <IEnumerable <KeyValuePair <string, string> > > ProcessAdapters(ConfigurationSetting setting, CancellationToken cancellationToken) { List <KeyValuePair <string, string> > keyValues = null; foreach (IKeyValueAdapter adapter in _options.Adapters) { if (!adapter.CanProcess(setting)) { continue; } IEnumerable <KeyValuePair <string, string> > kvs = await adapter.ProcessKeyValue(setting, cancellationToken).ConfigureAwait(false); if (kvs != null) { keyValues = keyValues ?? new List <KeyValuePair <string, string> >(); keyValues.AddRange(kvs); } } return(keyValues ?? Enumerable.Repeat(new KeyValuePair <string, string>(setting.Key, setting.Value), 1)); }
private string getGlobalSetting( string optionName ) { lock(_configurationCache) if (this._configurationCache.ContainsKey(optionName)) { ConfigurationSetting setting; if (this._configurationCache.TryGetValue(optionName, out setting)) { if (setting.isValid()) { return setting.value; } //option cache is not valid // fetch new item from database string optionValue1 = this.retrieveOptionFromDatabase(optionName); setting.value = optionValue1; this._configurationCache.Remove(optionName); this._configurationCache.Add(optionName, setting); return setting.value; } throw new ArgumentOutOfRangeException(); } string optionValue2 = this.retrieveOptionFromDatabase(optionName); if (optionValue2 != string.Empty) { ConfigurationSetting cachedSetting = new ConfigurationSetting(optionName, optionValue2); lock (_configurationCache) this._configurationCache.Add(optionName, cachedSetting); } return optionValue2; }
public static async Task <KeyValueChange> GetKeyValueChange(this ConfigurationClient client, ConfigurationSetting setting, CancellationToken cancellationToken) { if (setting == null) { throw new ArgumentNullException(nameof(setting)); } if (string.IsNullOrEmpty(setting.Key)) { throw new ArgumentNullException($"{nameof(setting)}.{nameof(setting.Key)}"); } try { Response <ConfigurationSetting> response = await client.GetConfigurationSettingAsync(setting, onlyIfChanged : true, cancellationToken).ConfigureAwait(false); if (response.GetRawResponse().Status == (int)HttpStatusCode.OK) { return(new KeyValueChange { ChangeType = KeyValueChangeType.Modified, Current = response.Value, Key = setting.Key, Label = setting.Label }); } } catch (RequestFailedException e) when(e.Status == (int)HttpStatusCode.NotFound && setting.ETag != default) { return(new KeyValueChange { ChangeType = KeyValueChangeType.Deleted, Current = null, Key = setting.Key, Label = setting.Label }); } return(new KeyValueChange { ChangeType = KeyValueChangeType.None, Current = setting, Key = setting.Key, Label = setting.Label }); }
public void addToConfigCache(string key, ConfigurationSetting value) { lock (_configurationCache) _configurationCache.Add(key, value); }
/// <summary> /// Deserializes the specified configuration in a <see cref="Insert"/> object. /// </summary> /// <param name="modelStore">The model store.</param> /// <param name="config">The config.</param> /// <param name="configurationSetting"></param> /// <returns></returns> public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { BaseDeserialize(modelStore, config, configurationSetting); SelectKey selectKey = BuildSelectKey(modelStore, config, configurationSetting); return(new Insert( id, parameterClass, parameterMap, resultClass, resultsMap, null, null, cacheModel, remapResults, extendsName, selectKey, sqlSource, preserveWhitespace )); }
public static ConfigurationSetting CloneSetting(ConfigurationSetting setting) { return(ConfigurationModelFactory.ConfigurationSetting(setting.Key, setting.Value, setting.Label, setting.ContentType, setting.ETag, setting.LastModified)); }
public async Task GetBatch() { var response1 = new MockResponse(200); response1.SetContent(SerializationHelpers.Serialize(new [] { CreateSetting(0), CreateSetting(1), }, SerializeBatch)); response1.AddHeader(new HttpHeader("Link", $"</kv?after=5>;rel=\"next\"")); var response2 = new MockResponse(200); response2.SetContent(SerializationHelpers.Serialize(new [] { CreateSetting(2), CreateSetting(3), CreateSetting(4), }, SerializeBatch)); var mockTransport = new MockTransport(response1, response2); ConfigurationClient service = CreateTestService(mockTransport); var query = new SettingSelector(); int keyIndex = 0; while (true) { using (Response <SettingBatch> response = await service.GetBatchAsync(query, CancellationToken.None)) { SettingBatch batch = response.Value; for (int i = 0; i < batch.Count; i++) { ConfigurationSetting value = batch[i]; Assert.AreEqual("key" + keyIndex, value.Key); keyIndex++; } var nextBatch = batch.NextBatch; if (nextBatch == null) { break; } query = nextBatch; } } Assert.AreEqual(2, mockTransport.Requests.Count); MockRequest request1 = mockTransport.Requests[0]; Assert.AreEqual(HttpPipelineMethod.Get, request1.Method); Assert.AreEqual("https://contoso.azconfig.io/kv/?key=*&label=*", request1.Uri.ToString()); AssertRequestCommon(request1); MockRequest request2 = mockTransport.Requests[1]; Assert.AreEqual(HttpPipelineMethod.Get, request2.Method); Assert.AreEqual("https://contoso.azconfig.io/kv/?key=*&label=*&after=5", request2.Uri.ToString()); AssertRequestCommon(request1); }
public async Task HelloWorldExtended() { var connectionString = TestEnvironment.ConnectionString; #region Snippet:AzConfigSample2_CreateConfigurationClient var client = new ConfigurationClient(connectionString); #endregion #region Snippet:AzConfigSample2_CreateConfigurationSettingAsync var betaEndpoint = new ConfigurationSetting("endpoint", "https://beta.endpoint.com", "beta"); var betaInstances = new ConfigurationSetting("instances", "1", "beta"); var productionEndpoint = new ConfigurationSetting("endpoint", "https://production.endpoint.com", "production"); var productionInstances = new ConfigurationSetting("instances", "1", "production"); #endregion #region Snippet:AzConfigSample2_AddConfigurationSettingAsync await client.AddConfigurationSettingAsync(betaEndpoint); await client.AddConfigurationSettingAsync(betaInstances); await client.AddConfigurationSettingAsync(productionEndpoint); await client.AddConfigurationSettingAsync(productionInstances); #endregion #region Snippet:AzConfigSample2_GetConfigurationSettingAsync ConfigurationSetting instancesToUpdate = await client.GetConfigurationSettingAsync(productionInstances.Key, productionInstances.Label); #endregion #region Snippet:AzConfigSample2_SetUpdatedConfigurationSettingAsync instancesToUpdate.Value = "5"; await client.SetConfigurationSettingAsync(instancesToUpdate); #endregion #region Snippet:AzConfigSample2_GetConfigurationSettingsAsync var selector = new SettingSelector { LabelFilter = "production" }; Debug.WriteLine("Settings for Production environment:"); await foreach (ConfigurationSetting setting in client.GetConfigurationSettingsAsync(selector)) { Console.WriteLine(setting); } #endregion // Delete the Configuration Settings from the Configuration Store. #region Snippet:AzConfigSample2_DeleteConfigurationSettingAsync await client.DeleteConfigurationSettingAsync(betaEndpoint.Key, betaEndpoint.Label); await client.DeleteConfigurationSettingAsync(betaInstances.Key, betaInstances.Label); await client.DeleteConfigurationSettingAsync(productionEndpoint.Key, productionEndpoint.Label); await client.DeleteConfigurationSettingAsync(productionInstances.Key, productionInstances.Label); #endregion }
public bool CanProcess(ConfigurationSetting setting) { string contentType = setting?.ContentType?.Split(';')[0].Trim(); return(string.Equals(contentType, KeyVaultConstants.ContentType)); }
/// <summary> Uses the Azure Key Vault secret provider to resolve Key Vault references retrieved from Azure App Configuration. </summary> /// <param KeyValue ="IKeyValue"> inputs the IKeyValue </param> /// returns the keyname and actual value public async Task <IEnumerable <KeyValuePair <string, string> > > ProcessKeyValue(ConfigurationSetting setting, CancellationToken cancellationToken) { KeyVaultSecretReference secretRef; // Content validation try { secretRef = JsonSerializer.Deserialize <KeyVaultSecretReference>(setting.Value); } catch (JsonException e) { throw CreateKeyVaultReferenceException("Invalid Key Vault reference", setting, e, null); } // Uri validation if (string.IsNullOrEmpty(secretRef.Uri) || !Uri.TryCreate(secretRef.Uri, UriKind.Absolute, out Uri secretUri) || secretUri.Segments.Length < 3) { throw CreateKeyVaultReferenceException("Invalid Key vault secret identifier", setting, null, secretRef); } string secret; try { secret = await _secretProvider.GetSecretValue(secretUri, cancellationToken).ConfigureAwait(false); } catch (UnauthorizedAccessException e) { throw CreateKeyVaultReferenceException(e.Message, setting, e, secretRef); } catch (Exception e) when(e is RequestFailedException || ((e as AggregateException)?.InnerExceptions?.All(e => e is RequestFailedException) ?? false)) { throw CreateKeyVaultReferenceException("Key vault error", setting, e, secretRef); } return(new KeyValuePair <string, string>[] { new KeyValuePair <string, string>(setting.Key, secret) }); }
private IList <IReportRow2> getRows(IList <string> columns, IReportFilterNode filterNode) { IList <IReportRow2> reportRows = new List <IReportRow2>(); IRecordContext _context = ((SrmReportTablePackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace; IIncident incidentRecord = null; int convId = 0, bundleId = 0; String endpoint = null; if (_context != null) { incidentRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident; convId = ConfigurationSetting.getSrmCustomAttr(incidentRecord, "srm_conversation_id"); bundleId = ConfigurationSetting.getSrmCustomAttr(incidentRecord, "srm_bundle_id"); if (convId == 0 || bundleId == 0) { return(reportRows); } } else { if (filterNode != null && filterNode.FilterNodes != null) { IReportFilterNode convIDFilterNode = filterNode.FilterNodes.ToList <IReportFilterNode>().Find(fn => fn.ReportFilter.Expression == string.Format("{0}${1}.ConversationID", this.Parent.Name, this.Name)); if (convIDFilterNode != null) { convId = Convert.ToInt32(convIDFilterNode.ReportFilter.Value); } if (convId == 0) { return(reportRows); } IReportFilterNode bundleIDFilterNode = filterNode.FilterNodes.ToList <IReportFilterNode>().Find(fn => fn.ReportFilter.Expression == string.Format("{0}${1}.BundleID", this.Parent.Name, this.Name)); if (bundleIDFilterNode != null) { bundleId = Convert.ToInt32(bundleIDFilterNode.ReportFilter.Value); } } } endpoint = String.Format(ConfigurationSetting.convReplyGETEndpoint, convId, bundleId, ConfigurationSetting.max_srm_rows_fetch); // determine whether to close or re-open a conversation String jsonStr = "{\"status\" : \"active\"}"; HttpContent content = new StringContent(jsonStr, Encoding.UTF8, "application/json"); ConfigurationSetting.logWrap.DebugLog(logMessage: Accelerator.SRM.SharedServices.Properties.Resources.GETRequestMessage, logNote: endpoint); var results = RESTHelper.PerformGET(endpoint, ref ((SrmReportTablePackage)this.Parent)._globalContext); if (results != null) { if (!results.Success) { MessageBox.Show(Properties.Resources.GetRowsError, Properties.Resources.Error); ConfigurationSetting.logWrap.ErrorLog(logMessage: "Response GET Conversation message error", logNote: results.JSON); } var jsonData = results.JSON; if (jsonData == null || jsonData == "") { return(reportRows); } JavaScriptSerializer ser = new JavaScriptSerializer(); RootObject replies = ser.Deserialize <RootObject>(jsonData); foreach (Item req in replies.items) { ReportDataRow reportDataRow = new ReportDataRow(this.Columns.Count); object reportDataKey = req.id; foreach (var column in columns) { ReportDataCell reportDataCell = new ReportDataCell(); switch (column) { case "SRM_Data$SrmRepliesListTable.ReplyID": reportDataCell.GenericValue = req.content.id; break; case "SRM_Data$SrmRepliesListTable.liked": reportDataCell.GenericValue = Convert.ToBoolean(req.content.liked); break; case "SRM_Data$SrmRepliesListTable.likesCount": reportDataCell.GenericValue = Convert.ToInt32(req.content.likesCount); break; case "SRM_Data$SrmRepliesListTable.authorName": reportDataCell.GenericValue = req.content.author.name; break; case "SRM_Data$SrmRepliesListTable.authorImage": reportDataCell.GenericValue = req.content.author.authorImage; break; case "SRM_Data$SrmRepliesListTable.attachmentType": reportDataCell.GenericValue = req.content.attachments != null ? req.content.attachments[0].type : null; break; case "SRM_Data$SrmRepliesListTable.attachmentUrl": reportDataCell.GenericValue = req.content.attachments != null ? req.content.attachments[0].url : null; break; case "SRM_Data$SrmRepliesListTable.authorProfileUrl": reportDataCell.GenericValue = req.content.author.authorProfileUrl; break; case "SRM_Data$SrmRepliesListTable.externalId": reportDataCell.GenericValue = req.content.externalId; break; case "SRM_Data$SrmRepliesListTable.type": reportDataCell.GenericValue = req.content.type; break; case "SRM_Data$SrmRepliesListTable.postedAt": DateTime utcTime = DateTime.Parse(req.content.postedAt); DateTime localTime = utcTime.ToLocalTime(); reportDataCell.GenericValue = localTime != null?localTime.ToString() : ""; break; case "SRM_Data$SrmRepliesListTable.status": reportDataCell.GenericValue = req.content.status; break; case "SRM_Data$SrmRepliesListTable.body": reportDataCell.GenericValue = req.content.body; break; case "SRM_Data$SrmRepliesListTable.labels": if (req.content.labels.Count == 0) { reportDataCell.GenericValue = "No Value"; } else { foreach (String label in req.content.labels) { reportDataCell.GenericValue += ", " + label; } } break; } reportDataRow.Cells.Add(reportDataCell); } //Please set the Key, it is necessary to edit report cell reportDataRow.Key = reportDataKey; reportRows.Add(reportDataRow); } } return(reportRows); }
private bool ReadAttributeValue(string line, ConfigurationSetting s) { string attributeName; line = line.TrimStart(); if (line.Length > 0 && line[0] == '[') { var closeBraceIndex = line.IndexOf(']'); if (closeBraceIndex >= 0) { attributeName = line.Substring(1, closeBraceIndex - 1); var value = line.Substring(closeBraceIndex + 1).Trim(); if (attributeName.EqualsOrdinal(ConfigurationSettingAttributeNames.Category)) { s.Category = value; return true; } else if (attributeName.EqualsOrdinal(ConfigurationSettingAttributeNames.Description)) { s.Description = value; return true; } else if (attributeName.EqualsOrdinal(ConfigurationSettingAttributeNames.Editor)) { s.EditorType = value; return true; } } } return false; }
public void Update(string id, ConfigurationSetting configSetting) { _configSettingCollection.ReplaceOne(c => c.Id == id, configSetting); }
private bool ParseSetting(string text, int lineNumber, ConfigurationSetting s) { if (string.IsNullOrWhiteSpace(text)) { return false; } IRValueNode leftOperand; IRValueNode rightOperand; if (ParseAssignment(text, out leftOperand, out rightOperand)) { var listOp = leftOperand as IOperator; if (listOp != null) { // Look for assignment on settings environment: // settings$name1 <- "value1" // settings$name1 <- expr1 if (listOp.OperatorType == OperatorType.ListIndex && listOp.LeftOperand != null && listOp.RightOperand != null) { var value = text.Substring(rightOperand.Start, rightOperand.Length); var listName = (listOp.LeftOperand as Variable)?.Name; var settingsName = (listOp.RightOperand as Variable)?.Name; var result = !string.IsNullOrEmpty(settingsName) && !string.IsNullOrEmpty(value); if (result && listName == "settings") { try { s.Name = settingsName; s.ValueType = value[0] == '\'' || value[0] == '\"' ? ConfigurationSettingValueType.String : ConfigurationSettingValueType.Expression; s.Value = s.ValueType == ConfigurationSettingValueType.String ? value.FromRStringLiteral() : value; return true; } catch (FormatException) { } } } } else { // Look for assignment with no environment // (backwards compat with RTVS 0.5 + creation of settings environment): // name1 <- "value1" // name1 <- expr1 var name = (leftOperand as Variable)?.Name; var value = text.Substring(rightOperand.Start, rightOperand.Length); var result = !string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(value); if (result) { try { s.Name = name; s.ValueType = value[0] == '\'' || value[0] == '\"' ? ConfigurationSettingValueType.String : ConfigurationSettingValueType.Expression; s.Value = s.ValueType == ConfigurationSettingValueType.String ? value.FromRStringLiteral() : value; return true; } catch (FormatException) { } } } } _errors.Add(new ConfigurationError(lineNumber, Resources.ConfigurationError_Syntax)); return false; }
public void Remove(ConfigurationSetting configSetting) { _configSettingCollection.DeleteOne(c => c.Id == configSetting.Id); }
private async Task RefreshIndividualKeyValues() { bool shouldRefreshAll = false; foreach (KeyValueWatcher changeWatcher in _options.ChangeWatchers) { string watchedKey = changeWatcher.Key; string watchedLabel = changeWatcher.Label; var timeElapsedSinceLastRefresh = DateTimeOffset.UtcNow - changeWatcher.LastRefreshTime; // Skip the refresh for this key if the cached value has not expired or a refresh operation is in progress if (timeElapsedSinceLastRefresh < changeWatcher.CacheExpirationTime || !changeWatcher.Semaphore.Wait(0)) { continue; } try { bool hasChanged = false; ConfigurationSetting watchedKv = null; if (_settings.ContainsKey(watchedKey) && _settings[watchedKey].Label == watchedLabel.NormalizeNull()) { watchedKv = _settings[watchedKey]; KeyValueChange keyValueChange = default; await TracingUtils.CallWithRequestTracing(_requestTracingEnabled, RequestType.Watch, _hostType, async() => keyValueChange = await _client.GetKeyValueChange(watchedKv, CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false); changeWatcher.LastRefreshTime = DateTimeOffset.UtcNow; // Check if a change has been detected in the key-value registered for refresh if (keyValueChange.ChangeType != KeyValueChangeType.None) { ProcessChanges(Enumerable.Repeat(keyValueChange, 1)); hasChanged = true; } } else { // Load the key-value in case the previous load attempts had failed var options = new SettingSelector { LabelFilter = watchedLabel }; try { await CallWithRequestTracing(async() => watchedKv = await _client.GetConfigurationSettingAsync(watchedKey, watchedLabel, CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false); } catch (RequestFailedException e) when(e.Status == (int)HttpStatusCode.NotFound) { watchedKv = null; } changeWatcher.LastRefreshTime = DateTimeOffset.UtcNow; if (watchedKv != null) { // Add the key-value if it is not loaded, or update it if it was loaded with a different label _settings[watchedKey] = watchedKv; hasChanged = true; } } if (hasChanged) { if (changeWatcher.RefreshAll) { shouldRefreshAll = true; // Skip refresh for other key-values since refreshAll will populate configuration from scratch break; } else { await SetData(_settings).ConfigureAwait(false); } } } finally { changeWatcher.Semaphore.Release(); } } // Trigger a single refresh-all operation if a change was detected in one or more key-values with refreshAll: true if (shouldRefreshAll) { await LoadAll().ConfigureAwait(false); } }
/// <summary> /// Deserializes the specified configuration in a Statement object. /// </summary> /// <param name="modelStore"></param> /// <param name="config">The config.</param> /// <param name="configurationSetting">Default settings.</param> /// <returns></returns> /// <remarks> /// Updated By: Richard Beacroft /// Updated Date: 11\10\2013 /// Description: configurationSetting can be null and therefore references to it have to assume that it could be null. /// </remarks> protected void BaseDeserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting) { // DefaultModelBuilderTest.Test_DefaultModelBuilder assumes that configurationSetting can be null - added code accordingly. // Typically, no public method should allow null to be passed-in, best handled by overloading method to exclude parameter, or in .NET 4, use optional parameter. var preserveWhitespace = (configurationSetting == null) ? false : configurationSetting.PreserveWhitespace; bool useStatementNamespaces = (configurationSetting == null) ? false : configurationSetting.UseStatementNamespaces; nameSpace = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_NAMESPACE); id = useStatementNamespaces ? ApplyNamespace(nameSpace, config.Id) : config.Id; cacheModelName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_CACHEMODEL); extendsName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_EXTENDS); listClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_LISTCLASS); parameterClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERCLASS); parameterMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PARAMETERMAP); resultClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTCLASS); resultMapName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_RESULTMAP); remapResults = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_REMAPRESULTS, false); sqlSourceClassName = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SQLSOURCE); preserveWhitespace = ConfigurationUtils.GetBooleanAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PRESERVEWHITSPACE, preserveWhitespace); // Gets the results Map if (resultMapName.Length > 0) { string[] ids = resultMapName.Split(','); for (int i = 0; i < ids.Length; i++) { string name = ApplyNamespace(nameSpace, ids[i].Trim()); resultsMap.Add(modelStore.GetResultMap(name)); } } // Gets the results class if (resultClassName.Length > 0) { string[] classNames = resultClassName.Split(','); for (int i = 0; i < classNames.Length; i++) { resultClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(classNames[i].Trim()); IFactory resultClassFactory = null; if (Type.GetTypeCode(resultClass) == TypeCode.Object && (resultClass.IsValueType == false) && resultClass != typeof(DataRow)) { resultClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(resultClass, Type.EmptyTypes); } IDataExchange dataExchange = modelStore.DataExchangeFactory.GetDataExchangeForClass(resultClass); bool isSimpleType = modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(resultClass); IResultMap autoMap = new AutoResultMap(resultClass, resultClassFactory, dataExchange, isSimpleType); resultsMap.Add(autoMap); } } // Gets the ParameterMap if (parameterMapName.Length > 0) { parameterMap = modelStore.GetParameterMap(parameterMapName); } // Gets the ParameterClass if (parameterClassName.Length > 0) { parameterClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(parameterClassName); } // Gets the listClass if (listClassName.Length > 0) { listClass = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(listClassName); listClassFactory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(listClass, Type.EmptyTypes); } // Gets the CacheModel if (cacheModelName.Length > 0) { cacheModel = modelStore.GetCacheModel(cacheModelName); } // Gets the SqlSource if (sqlSourceClassName.Length > 0) { Type sqlSourceType = modelStore.DataExchangeFactory.TypeHandlerFactory.GetType(sqlSourceClassName); IFactory factory = modelStore.DataExchangeFactory.ObjectFactory.CreateFactory(sqlSourceType, Type.EmptyTypes); sqlSource = (ISqlSource)factory.CreateInstance(null); } }