public void AccessInheritedPropertyFromBaseClass() { IDynamicProperty p = Create(typeof(ClassWithNonReadableProperty).GetProperty("MyBaseProperty")); BaseClass baseObject = new BaseClass(); baseObject.MyBaseProperty = "testtext"; Assert.AreEqual("testtext", p.GetValue(baseObject)); }
public void TestNonReadableProperties() { IDynamicProperty nonReadableProperty = Create(typeof(ClassWithNonReadableProperty).GetProperty("MyProperty")); nonReadableProperty.GetValue(null); }
internal virtual bool AddDynamicProperty(IDynamicProperty prop) { lock (this) { DynamicPropertyHolder.CheckPropertyNameClash(prop.Name, this._props, this._numProps); bool flag = false; if (this._props == null || this._numProps == this._props.Length) { this._props = DynamicPropertyHolder.GrowPropertiesArray(this._props); flag = true; } this._props[this._numProps++] = prop; if (flag) { this._sinks = DynamicPropertyHolder.GrowDynamicSinksArray(this._sinks); } if (this._sinks == null) { this._sinks = new IDynamicMessageSink[this._props.Length]; for (int index = 0; index < this._numProps; ++index) { this._sinks[index] = ((IContributeDynamicSink)this._props[index]).GetDynamicSink(); } } else { this._sinks[this._numProps - 1] = ((IContributeDynamicSink)prop).GetDynamicSink(); } return(true); } }
public void AccessInheritedPropertyFromDerivedClass() { IDynamicProperty p = Create(typeof(BaseClass).GetProperty("MyBaseProperty")); ClassWithNonReadableProperty derivedObject = new ClassWithNonReadableProperty(); derivedObject.MyBaseProperty = "testtext"; Assert.AreEqual("testtext", p.GetValue(derivedObject)); }
/*package*/ internal bool AddServerSideDynamicProperty( IDynamicProperty prop) { if (_dphSrv == null) { DynamicPropertyHolder dphSrv = new DynamicPropertyHolder(); bool fLocked = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this, ref fLocked); if (_dphSrv == null) { _dphSrv = dphSrv; } } finally { if (fLocked) { Monitor.Exit(this); } } } return(_dphSrv.AddDynamicProperty(prop)); }
} // RemoveIdentity // Support for dynamically registered property sinks internal static bool AddDynamicProperty(MarshalByRefObject obj, IDynamicProperty prop) { if (RemotingServices.IsObjectOutOfContext(obj)) { // We have to add a proxy side property, get the identity RealProxy rp = RemotingServices.GetRealProxy(obj); return(rp.IdentityObject.AddProxySideDynamicProperty(prop)); } else { MarshalByRefObject realObj = (MarshalByRefObject) RemotingServices.AlwaysUnwrap((ContextBoundObject)obj); // This is a real object. See if we have an identity for it ServerIdentity srvID = (ServerIdentity)MarshalByRefObject.GetIdentity(realObj); if (srvID != null) { return(srvID.AddServerSideDynamicProperty(prop)); } else { // identity not found, we can't set a sink for this object. throw new RemotingException( Environment.GetResourceString("Remoting_NoIdentityEntry")); } } }
public void TestAttemptingToSetPropertyOfValueTypeInstance() { MyStruct myYearHolder = new MyStruct(); IDynamicProperty year = Create(typeof(MyStruct).GetProperty("Year")); Assert.Throws <InvalidOperationException>(() => year.SetValue(myYearHolder, 2004)); }
public void TestNonWritableStaticProperty() { IDynamicProperty nonWritableProperty = Create(typeof(DateTime).GetProperty("Today")); nonWritableProperty.SetValue(null, null); }
public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, Context ctx) { bool fRegistered = false; if (prop == null || prop.Name == null || !(prop is IContributeDynamicSink)) { throw new ArgumentNullException("prop"); } if (obj != null && ctx != null) { // Exactly one of these is allowed to be non-null. throw new ArgumentException(Environment.GetResourceString("Argument_NonNullObjAndCtx")); } if (obj != null) { // ctx is ignored and must be null. fRegistered = IdentityHolder.AddDynamicProperty(obj, prop); } else { // ctx may or may not be null fRegistered = Context.AddDynamicProperty(ctx, prop); } return(fRegistered); }
protected PBSEffectNode() { _standingController = new PBSStandingController <PBSEffectNode>(this) { AlwaysEnabled = true }; _coreUseHandler = new CoreUseHandler <PBSEffectNode>(this, new EnergyStateFactory(this)); _currentEffect = DynamicProperties.GetProperty <int>(k.currentEffect); _currentEffect.PropertyChanging += (property, value) => { var effectType = (EffectType)value; if (effectType == EffectType.undefined) { effectType = AvailableEffects.FirstOrDefault(); } if (!AvailableEffects.Contains(effectType)) { Logger.Error("PBSEffectNode: invalid effect type! type:" + effectType); } RemoveCurrentEffect(); return((int)effectType); }; _currentEffect.PropertyChanged += property => { OnEffectChanged(); }; }
internal virtual bool AddDynamicProperty(IDynamicProperty prop) { lock (this) { CheckPropertyNameClash(prop.Name, this._props, this._numProps); bool flag = false; if ((this._props == null) || (this._numProps == this._props.Length)) { this._props = GrowPropertiesArray(this._props); flag = true; } this._props[this._numProps++] = prop; if (flag) { this._sinks = GrowDynamicSinksArray(this._sinks); } if (this._sinks == null) { this._sinks = new IDynamicMessageSink[this._props.Length]; for (int i = 0; i < this._numProps; i++) { this._sinks[i] = ((IContributeDynamicSink) this._props[i]).GetDynamicSink(); } } else { this._sinks[this._numProps - 1] = ((IContributeDynamicSink) prop).GetDynamicSink(); } return true; } }
/// <summary> /// /// </summary> /// <param name="objectType"></param> /// <param name="propertyName"></param> /// <returns></returns> public static IDynamicProperty GetDynamicProperty(Type objectType, string propertyName) { Guard.ArgumentNotNull(objectType, "objectType"); Guard.ArgumentNotNullOrEmpty(propertyName, "propertyName"); MethodCacheKey key = MethodCacheKey.Create(objectType.FullName, propertyName, TypeHelper.GetParameterTypes()); IDynamicProperty dynamicProperty = null; if (!_dynamicProperties.TryGetValue(key, out dynamicProperty)) { lock (_syncObj) { if (!_dynamicProperties.TryGetValue(key, out dynamicProperty)) { PropertyInfo propertyInfo = objectType.GetProperty(propertyName, propertyFlags); if (propertyInfo == null) { ThrowHelper.ThrowInvalidOperationException(ReflectionSR.PropertyNotFound, objectType.FullName, propertyName); } dynamicProperty = DynamicProperty.Create(propertyInfo); _dynamicProperties.Add(key, dynamicProperty); } } } return(dynamicProperty); }
public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, Context ctx) { Contract.Requires(prop != null); Contract.Requires(obj == null || ctx == null); return(default(bool)); }
public void TestNonWritableInstanceProperty() { IDynamicProperty nonWritableProperty = Create(typeof(Inventor).GetProperty("PlaceOfBirth")); nonWritableProperty.SetValue(null, null); }
public ValueChangedDisposable(IDynamicProperty property, Action onValueChanged) { _property = property ?? throw new ArgumentNullException(nameof(property)); _onValueChanged = onValueChanged ?? throw new ArgumentNullException(nameof(onValueChanged)); _property.ValueChanged += OnValueChanged; }
public void TestAttemptingToSetPropertyOfValueTypeInstance() { MyStruct myYearHolder = new MyStruct(); IDynamicProperty year = Create(typeof(MyStruct).GetProperty("Year")); year.SetValue(myYearHolder, 2004); }
public void PerformanceTests() { int n = 10000000; object x = null; // tesla.PlaceOfBirth start = DateTime.Now; for (int i = 0; i < n; i++) { x = tesla.PlaceOfBirth; } stop = DateTime.Now; PrintTest("tesla.PlaceOfBirth (direct)", n, Elapsed); start = DateTime.Now; IDynamicProperty placeOfBirth = DynamicProperty.Create(typeof(Inventor).GetProperty("PlaceOfBirth")); for (int i = 0; i < n; i++) { x = placeOfBirth.GetValue(tesla); } stop = DateTime.Now; PrintTest("tesla.PlaceOfBirth (dynamic reflection)", n, Elapsed); start = DateTime.Now; PropertyInfo placeOfBirthPi = typeof(Inventor).GetProperty("PlaceOfBirth"); for (int i = 0; i < n; i++) { x = placeOfBirthPi.GetValue(tesla, null); } stop = DateTime.Now; PrintTest("tesla.PlaceOfBirth (standard reflection)", n, Elapsed); }
internal bool AddServerSideDynamicProperty(IDynamicProperty prop) { if (this._dphSrv == null) { DynamicPropertyHolder holder = new DynamicPropertyHolder(); bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(this, ref lockTaken); if (this._dphSrv == null) { this._dphSrv = holder; } } finally { if (lockTaken) { Monitor.Exit(this); } } } return(this._dphSrv.AddDynamicProperty(prop)); }
public DynamicPropertyValidationDisposable(IDynamicProperty property, Func <CancellationToken, IDynamicProperty, Task> validationFunc) { _property = property ?? throw new ArgumentNullException(nameof(property)); _validationFunc = validationFunc ?? throw new ArgumentNullException(nameof(validationFunc)); _property.ValueChanged += OnValueChanged; }
internal CommandProperties([NotNull] string commandName) { this._commandName = commandName; CircuitBreakerForceClosed = this.Get <bool>("circuitBreaker.forceClosed", default_circuitBreakerForceClosed); CircuitBreakerForceOpen = this.Get <bool>("circuitBreaker.forceOpen", default_circuitBreakerForceOpen); CircuitBreakerRequestVolumeThreshold = this.Get <int>("circuitBreaker.requestVolumeThreshold", default_circuitBreakerRequestVolumeThreshold); CircuitBreakerErrorThresholdPercentage = this.Get <int>("circuitBreaker.errorThresholdPercentage", default_circuitBreakerErrorThresholdPercentage); CircuitBreakerSleepWindowInMilliseconds = this.Get <int>("circuitBreaker.sleepWindowInMilliseconds", default_circuitBreakerSleepWindowInMilliseconds); FallbackIsolationSemaphoreMaxConcurrentRequests = this.Get <int>("fallback.isolation.semaphore.maxConcurrentRequests", default_fallbackIsolationSemaphoreMaxConcurrentRequests); ExecutionIsolationSemaphoreMaxConcurrentRequests = this.Get <int>("execution.isolation.semaphore.maxConcurrentRequests", default_executionIsolationSemaphoreMaxConcurrentRequests); ExecutionIsolationThreadTimeoutInMilliseconds = this.Get <int>("execution.isolation.thread.timeoutInMilliseconds", default_executionTimeoutInMilliseconds); CircuitBreakerEnabled = this.Get <bool>("circuitBreaker.enabled", default_circuitBreakerEnabled); MetricsRollingStatisticalWindowInMilliseconds = this.Get <int>("metrics.rollingStats.timeInMilliseconds", default_metricsRollingStatisticalWindow); RequestCacheEnabled = this.Get <bool>("requestCache.enabled", default_requestCacheEnabled); RequestLogEnabled = this.Get <bool>("requestLog.enabled", default_requestLogEnabled); MetricsRollingStatisticalWindowBuckets = this.Get <int>("metrics.rollingStats.numBuckets", default_metricsRollingStatisticalWindowBuckets); MetricsRollingPercentileWindowBuckets = this.Get <int>("metrics.rollingPercentile.numBuckets", default_metricsRollingPercentileWindowBuckets); MetricsRollingPercentileWindowInMilliseconds = this.Get <int>("metrics.rollingPercentile.timeInMilliseconds", default_metricsRollingPercentileWindow); MetricsRollingPercentileEnabled = this.Get <bool>("metrics.rollingPercentile.enabled", default_metricsRollingPercentileEnabled); MetricsRollingPercentileBucketSize = this.Get <int>("metrics.rollingPercentile.bucketSize", default_metricsRollingPercentileBucketSize); MetricsHealthSnapshotIntervalInMilliseconds = this.Get <int>("metrics.healthSnapshot.intervalInMilliseconds", default_metricsHealthSnapshotIntervalInMilliseconds); FallbackEnabled = this.Get <bool>("fallback.enabled", default_fallbackEnabled); ExecutionTimeoutEnabled = this.Get <bool>("execution.timeout.enabled", default_executionTimeoutEnabled); ExecutionIsolationStrategy = this.Get <ExecutionIsolationStrategy>("execution.isolation.strategy", default_executionIsolationStratgey); }
public void Dispose() { TryCancelExecution(); _property.ValueChanged -= OnValueChanged; _property = null; }
internal bool AddServerSideDynamicProperty(IDynamicProperty prop) { if (this._dphSrv == null) { DynamicPropertyHolder holder = new DynamicPropertyHolder(); bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(this, ref lockTaken); if (this._dphSrv == null) { this._dphSrv = holder; } } finally { if (lockTaken) { Monitor.Exit(this); } } } return this._dphSrv.AddDynamicProperty(prop); }
public bool RegisterDynamicProperty(IDynamicProperty prop) { lock (this) { if (FindProperty(prop.Name) != -1) { throw new InvalidOperationException("Another property by this name already exists"); } // Make a copy, do not interfere with threads running dynamic sinks ArrayList newProps = new ArrayList(_properties); DynamicPropertyReg reg = new DynamicPropertyReg(); reg.Property = prop; IContributeDynamicSink contributor = prop as IContributeDynamicSink; if (contributor != null) { reg.Sink = contributor.GetDynamicSink(); } newProps.Add(reg); _properties = newProps; return(true); // When should be false? } }
internal static bool AddDynamicProperty(Context ctx, IDynamicProperty prop) { if (ctx != null) { return ctx.AddPerContextDynamicProperty(prop); } return AddGlobalDynamicProperty(prop); }
internal static bool AddDynamicProperty(Context ctx, IDynamicProperty prop) { if (ctx != null) { return(ctx.AddPerContextDynamicProperty(prop)); } return(Context.AddGlobalDynamicProperty(prop)); }
public void TestStaticProperties() { IDynamicProperty today = Create(typeof(DateTime).GetProperty("Today")); Assert.AreEqual(DateTime.Today, today.GetValue(null)); IDynamicProperty myProperty = Create(typeof(MyStaticClass).GetProperty("MyProperty")); myProperty.SetValue(null, "here we go..."); Assert.AreEqual("here we go...", myProperty.GetValue(null)); }
public void SetValue <TValue>(string name, TValue value) { IDynamicProperty property = GetProperty(name); if (property != null) { property.Value = value; } }
public LootContainer(ILootItemRepository lootItemRepository) { _looters = new Looters(this); _itemRepository = lootItemRepository; _lootListPacketBuilder = new LootListPacketBuilder(this, _itemRepository); _pinCode = DynamicProperties.GetProperty <int>(k.pinCode); }
/// <summary> /// Subscribes to the changes in the value of the <paramref name="property"/> and invokes the /// <paramref name="onValueChanged"/> callback. /// </summary> /// <typeparam name="T">The type of the property.</typeparam> /// <param name="property">The property to subscribe to.</param> /// <param name="onValueChanged">The callback.</param> /// <returns><see cref="IDisposable"/></returns> public static IDisposable Subscribe <T>(this IDynamicProperty <T> property, Action <IDynamicProperty <T> > onValueChanged) { if (onValueChanged is null) { throw new ArgumentNullException(nameof(onValueChanged)); } return(new ValueChangedDisposable(property, () => onValueChanged.Invoke(property))); }
public GeneratorDynamicProperty(IDynamicProperty dynamicProperty) { Source = dynamicProperty.Source; CSharpName = dynamicProperty.CSharpName; Result = dynamicProperty.Result; RootOperation = ConvertOperation(dynamicProperty.RootOperation); GeneratorDynamicPropertyMap.Add(dynamicProperty, this); }
internal static IDynamicProperty[] GrowPropertiesArray(IDynamicProperty[] props) { IDynamicProperty[] dynamicPropertyArray = new IDynamicProperty[(props != null ? props.Length : 0) + 8]; if (props != null) { Array.Copy((Array)props, (Array)dynamicPropertyArray, props.Length); } return(dynamicPropertyArray); }
internal void OnPropertyChanged(IDynamicProperty property, PropertyChangedAction action) { var tmp = PropertyChanged; if (tmp != null) { tmp(this, new DynamicPropertyChangedEventArgs(property, action)); } }
private static UnboundColumnType GetUnboundType(IDynamicProperty property) { UnboundColumnType unboundType; if (property.GetPropertyType() == typeof(string)) { unboundType = UnboundColumnType.String; } else if (property.GetPropertyType() == typeof(double)) { unboundType = UnboundColumnType.Decimal; } else if (property.GetPropertyType() == typeof(double?)) { unboundType = UnboundColumnType.Decimal; } else if (property.GetPropertyType() == typeof(decimal)) { unboundType = UnboundColumnType.Decimal; } else if (property.GetPropertyType() == typeof(decimal?)) { unboundType = UnboundColumnType.Decimal; } else if (property.GetPropertyType() == typeof(int)) { unboundType = UnboundColumnType.Integer; } else if (property.GetPropertyType() == typeof(int?)) { unboundType = UnboundColumnType.Integer; } else if (property.GetPropertyType() == typeof(DateTime)) { unboundType = UnboundColumnType.DateTime; } else if (property.GetPropertyType() == typeof(DateTime?)) { unboundType = UnboundColumnType.DateTime; } else if (property.GetPropertyType() == typeof(bool)) { unboundType = UnboundColumnType.Boolean; } else if (property.GetPropertyType() == typeof(object)) { unboundType = UnboundColumnType.Object; } else { throw new PhuLiException(string.Format("Type [{0}] not handled. Please add this type to the function.", property.GetPropertyType().FullName)); } return(unboundType); }
internal static void CheckPropertyNameClash(string name, IDynamicProperty[] props, int count) { for (int i = 0; i < count; i++) { if (props[i].Name.Equals(name)) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DuplicatePropertyName")); } } }
internal static IDynamicProperty[] GrowPropertiesArray(IDynamicProperty[] props) { int num = ((props != null) ? props.Length : 0) + 8; IDynamicProperty[] destinationArray = new IDynamicProperty[num]; if (props != null) { Array.Copy(props, destinationArray, props.Length); } return destinationArray; }
internal static bool AddDynamicProperty(MarshalByRefObject obj, IDynamicProperty prop) { if (RemotingServices.IsObjectOutOfContext(obj)) { return RemotingServices.GetRealProxy(obj).IdentityObject.AddProxySideDynamicProperty(prop); } MarshalByRefObject obj2 = (MarshalByRefObject) RemotingServices.AlwaysUnwrap((ContextBoundObject) obj); ServerIdentity identity = (ServerIdentity) MarshalByRefObject.GetIdentity(obj2); if (identity == null) { throw new RemotingException(Environment.GetResourceString("Remoting_NoIdentityEntry")); } return identity.AddServerSideDynamicProperty(prop); }
/// <summary> /// Initializes a new instance of the <see cref="DbProvider"/> class. /// </summary> /// <param name="dbMetadata">The db metadata.</param> public DbProvider(IDbMetadata dbMetadata) { this.dbMetadata = dbMetadata; newCommand = DynamicConstructor.Create(dbMetadata.CommandType.GetConstructor(Type.EmptyTypes)); // Oracle needs custom bind by name property set to true as it's false by default var bindByNameProperty = dbMetadata.CommandType.GetProperty("BindByName"); if (bindByNameProperty != null && bindByNameProperty.CanWrite) { commandBindByName = DynamicProperty.Create(bindByNameProperty); } newConnection = DynamicConstructor.Create(dbMetadata.ConnectionType.GetConstructor(Type.EmptyTypes)); newCommandBuilder = DynamicConstructor.Create(dbMetadata.CommandBuilderType.GetConstructor(Type.EmptyTypes)); newDataAdapter = DynamicConstructor.Create(dbMetadata.DataAdapterType.GetConstructor(Type.EmptyTypes)); newParameter = DynamicConstructor.Create(dbMetadata.ParameterType.GetConstructor(Type.EmptyTypes)); }
[System.Security.SecurityCritical] // auto-generated internal virtual bool AddDynamicProperty(IDynamicProperty prop) { lock(this) { // We have to add a sink specific to the given context CheckPropertyNameClash(prop.Name, _props, _numProps); // check if we need to grow the array. bool bGrow=false; if (_props == null || _numProps == _props.Length) { _props = GrowPropertiesArray(_props); bGrow = true; } // now add the property _props[_numProps++] = prop; // we need to grow the sinks if we grew the props array or we had thrown // away the sinks array due to a recent removal! if (bGrow) { _sinks = GrowDynamicSinksArray(_sinks); } if (_sinks == null) { // Some property got unregistered -- we need to recreate // the list of sinks. _sinks = new IDynamicMessageSink[_props.Length]; for (int i=0; i<_numProps; i++) { _sinks[i] = ((IContributeDynamicSink)_props[i]).GetDynamicSink(); } } else { // append the Sink to the existing array of Sinks _sinks[_numProps-1] = ((IContributeDynamicSink)prop).GetDynamicSink(); } return true; } }
internal RollingPercentileNumber(IClock clock, int timeInMs, int numberOfBuckets, int dataLength, IDynamicProperty<bool> enabled) { this.enabled = enabled; this.TimeInMs = timeInMs; this.clock = clock; this.bucketSizeInMs = timeInMs / numberOfBuckets; var cx = numberOfBuckets + 1; // + one spare buckets = new Bucket[cx]; this.numberOfBuckets = numberOfBuckets; for (int i = 0; i < cx; i++) { buckets[i] = new Bucket(dataLength); } buckets[0].bucketStartInMs = clock.EllapsedTimeInMs; _percentileSnapshot = new PercentileSnapshot(GetBuckets().Select(b=>new SnapshotItem { Length = b.Length, Data = b.data }).ToArray()); }
internal bool AddProxySideDynamicProperty(IDynamicProperty prop) { lock (this) { if (this._dph == null) { DynamicPropertyHolder holder = new DynamicPropertyHolder(); lock (this) { if (this._dph == null) { this._dph = holder; } } } return this._dph.AddDynamicProperty(prop); } }
public static bool RegisterDynamicProperty (IDynamicProperty prop, ContextBoundObject obj, Context ctx) { Contract.Requires(prop != null); Contract.Requires(obj == null || ctx == null); return default(bool); }
public RollingPercentileNumber(int timeInMs, int numberOfBuckets, int dataLength, IDynamicProperty<bool> enabled) : this(Clock.GetInstance(), timeInMs, numberOfBuckets, dataLength, enabled) { }
[System.Security.SecurityCritical] // auto-generated internal bool AddProxySideDynamicProperty(IDynamicProperty prop) { lock(this) { if (_dph == null) { DynamicPropertyHolder dph = new DynamicPropertyHolder(); lock(this) { if (_dph == null) { _dph = dph; } } } return _dph.AddDynamicProperty(prop); } }
public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, Context ctx) { DynamicPropertyCollection col = GetDynamicPropertyCollection (obj, ctx); return col.RegisterDynamicProperty (prop); }
public TryableSemaphoreActual(IDynamicProperty<int> numberOfPermits) { this.NumberOfPermits = numberOfPermits; }
/*package*/ internal bool AddServerSideDynamicProperty( IDynamicProperty prop) { if (_dphSrv == null) { DynamicPropertyHolder dphSrv = new DynamicPropertyHolder(); lock (this) { if (_dphSrv == null) { _dphSrv = dphSrv; } } } return _dphSrv.AddDynamicProperty(prop); }
[System.Security.SecurityCritical] // auto-generated internal static bool AddDynamicProperty(Context ctx, IDynamicProperty prop) { // Check if we have a property by this name if (ctx != null) { return ctx.AddPerContextDynamicProperty(prop); } else { // We have to add a sink that should fire for all contexts return AddGlobalDynamicProperty(prop); } }
public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, Context ctx) { bool fRegistered = false; if (prop == null || prop.Name == null || !(prop is IContributeDynamicSink)) { throw new ArgumentNullException("prop"); } if (obj != null && ctx != null) { // Exactly one of these is allowed to be non-null. throw new ArgumentException(Environment.GetResourceString("Argument_NonNullObjAndCtx")); } if (obj != null) { // ctx is ignored and must be null. fRegistered = IdentityHolder.AddDynamicProperty(obj, prop); } else { // ctx may or may not be null fRegistered = Context.AddDynamicProperty(ctx, prop); } return fRegistered; }
/// <summary> /// Setup constructor /// </summary> /// <param name="category">Property setup</param> /// <param name="baseProperty">Dynamic property</param> public DynPropertySpec( string category, IDynamicProperty baseProperty ) : base(baseProperty.Name, baseProperty.Value.GetType( ), category, "", baseProperty.Value) { m_BaseProperty = baseProperty; }
/// <summary> /// Creates a new instance of the safe property wrapper. /// </summary> /// <param name="property">Property to wrap.</param> public SafeProperty(PropertyInfo property) { this.propertyInfo = property; if (property.CanRead && property.GetGetMethod() != null && ReflectionUtils.IsTypeVisible(property.DeclaringType, DynamicReflectionManager.ASSEMBLY_NAME)) { dynamicProperty = DynamicProperty.Create(property); isOptimizedGet = true; } canSet = property.CanWrite && !(propertyInfo.DeclaringType.IsValueType && !propertyInfo.GetSetMethod(true).IsStatic); if (property.GetSetMethod() != null && ReflectionUtils.IsTypeVisible(property.DeclaringType, DynamicReflectionManager.ASSEMBLY_NAME)) { if (dynamicProperty == null) { dynamicProperty = DynamicProperty.Create(property); } isOptimizedSet = true; } }
private bool AddPerContextDynamicProperty(IDynamicProperty prop) { if (this._dphCtx == null) { DynamicPropertyHolder holder = new DynamicPropertyHolder(); lock (this) { if (this._dphCtx == null) { this._dphCtx = holder; } } } return this._dphCtx.AddDynamicProperty(prop); }
public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, System.Runtime.Remoting.Contexts.Context ctx) { return default(bool); }
internal static IDynamicProperty[] GrowPropertiesArray(IDynamicProperty[] props) { // grow the array of IContextProperty objects int newSize = (props != null ? props.Length : 0) + GROW_BY; IDynamicProperty[] newProps = new IDynamicProperty[newSize]; if (props != null) { // Copy existing properties over. Array.Copy(props, newProps, props.Length); } return newProps; }
[System.Security.SecurityCritical] // auto-generated private bool AddPerContextDynamicProperty(IDynamicProperty prop) { if (_dphCtx == null) { DynamicPropertyHolder dph = new DynamicPropertyHolder(); lock (this) { if (_dphCtx == null) { _dphCtx = dph; } } } return _dphCtx.AddDynamicProperty(prop); }
[System.Security.SecurityCritical] // auto-generated private static bool AddGlobalDynamicProperty(IDynamicProperty prop) { return _dphGlobal.AddDynamicProperty(prop); }
[System.Security.SecurityCritical] // auto-generated internal bool AddServerSideDynamicProperty( IDynamicProperty prop) { if (_dphSrv == null) { DynamicPropertyHolder dphSrv = new DynamicPropertyHolder(); bool fLocked = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(this, ref fLocked); if (_dphSrv == null) { _dphSrv = dphSrv; } } finally { if (fLocked) { Monitor.Exit(this); } } } return _dphSrv.AddDynamicProperty(prop); }
[System.Security.SecurityCritical] // auto-generated internal static bool AddDynamicProperty(MarshalByRefObject obj, IDynamicProperty prop) { if (RemotingServices.IsObjectOutOfContext(obj)) { // We have to add a proxy side property, get the identity RealProxy rp = RemotingServices.GetRealProxy(obj); return rp.IdentityObject.AddProxySideDynamicProperty(prop); } else { MarshalByRefObject realObj = (MarshalByRefObject) RemotingServices.AlwaysUnwrap((ContextBoundObject)obj); // This is a real object. See if we have an identity for it ServerIdentity srvID = (ServerIdentity)MarshalByRefObject.GetIdentity(realObj); if (srvID != null) { return srvID.AddServerSideDynamicProperty(prop); } else { // identity not found, we can't set a sink for this object. throw new RemotingException( Environment.GetResourceString("Remoting_NoIdentityEntry")); } } }
public static bool RegisterDynamicProperty(IDynamicProperty prop, System.ContextBoundObject obj, Context ctx) {}
public bool RegisterDynamicProperty(IDynamicProperty prop) { lock (this) { if (FindProperty (prop.Name) != -1) throw new InvalidOperationException ("Another property by this name already exists"); // Make a copy, do not interfere with threads running dynamic sinks ArrayList newProps = new ArrayList (_properties); DynamicPropertyReg reg = new DynamicPropertyReg(); reg.Property = prop; IContributeDynamicSink contributor = prop as IContributeDynamicSink; if (contributor != null) reg.Sink = contributor.GetDynamicSink (); newProps.Add (reg); _properties = newProps; return true; // When should be false? } }
public static bool RegisterDynamicProperty (IDynamicProperty prop, ContextBoundObject obj, Context ctx) { // TODO return false; }