protected void EnsureRights(SymbolAccessRights requested) { if ((this.accessRights & requested) != requested) { throw new InsufficientAccessRights(this, requested); } }
internal Symbol(AdsSymbolEntry entry, ISymbol parent, ISymbolFactoryServices factoryServices) { this.accessRights = SymbolAccessRights.All; if (entry == null) { throw new ArgumentNullException("entry"); } if (factoryServices == null) { throw new ArgumentNullException("factoryServices"); } this.factoryServices = factoryServices; this.indexGroup = entry.indexGroup; this.indexOffset = entry.indexOffset; base.comment = entry.comment; base.dataTypeId = (AdsDatatypeId)entry.dataType; base.category = DataTypeCategory.Unknown; this.parent = parent; base.instanceName = this.getInstanceName(entry.name); this.instancePath = this.getInstancePath(entry.name); base.size = (int)entry.size; base.typeName = entry.type; base.resolvedDataType = null; base.flags = entry.flags; if (entry.attributeCount > 0) { base.attributes = new TypeAttributeCollection(entry.attributes); } }
private Symbol(uint indexGroup, uint indexOffset, ISymbol parent, IDataType type, string instanceName, string instancePath, ISymbolFactoryServices factoryServices) { this.accessRights = SymbolAccessRights.All; if (factoryServices == null) { throw new ArgumentNullException("factoryServices"); } if (string.IsNullOrEmpty(instanceName)) { throw new ArgumentOutOfRangeException("instanceName"); } this.factoryServices = factoryServices; this.parent = parent; if (parent != null) { base.Bind(((IBinderProvider)parent).Binder); } this.indexGroup = indexGroup; this.indexOffset = indexOffset; if (type != null) { base.dataTypeId = ((DataType)type).DataTypeId; base.category = type.Category; } base.instanceName = instanceName; this.instancePath = instancePath; if (string.IsNullOrEmpty(this.instancePath)) { if (parent == null) { this.instancePath = instanceName; } else if (type.IsPointer) { this.instancePath = parent.InstancePath + "." + instanceName; } else if (!parent.IsPointer) { this.instancePath = !parent.IsReference ? (parent.InstancePath + "." + instanceName) : parent.InstancePath; } else { base.instanceName = parent.InstanceName + "^"; this.instancePath = parent.InstancePath + "^"; } } base.SetContextMask(0); if (parent != null) { base.SetContextMask(((IContextMaskProvider)parent).ContextMask); } if (type != null) { base.flags = DataTypeFlagConverter.Convert(((DataType)type).Flags); base.size = type.Size; base.typeName = type.Name; } base.resolvedDataType = type; }
internal Symbol(int[] indices, bool oversampleElement, ISymbol parent) { this.accessRights = SymbolAccessRights.All; if (parent == null) { throw new ArgumentNullException("parent"); } this.factoryServices = ((ISymbolFactoryServicesProvider)parent).FactoryServices; this.parent = parent; base.Bind(((IBinderProvider)parent).Binder); string str = string.Empty; ArrayType type = (ArrayType)((DataType)parent.DataType).ResolveType(DataTypeResolveStrategy.AliasReference); type.CheckIndices(indices, oversampleElement); str = !oversampleElement?ArrayIndexConverter.IndicesToString(indices) : ArrayIndexConverter.OversamplingSubElementToString(type.Dimensions.ElementCount); base.instanceName = parent.InstanceName + str; this.instancePath = parent.InstancePath + str; DataType elementType = (DataType)type.ElementType; base.resolvedDataType = elementType; base.flags = this.getSymbolFlags(parent, elementType); if (base.resolvedDataType != null) { base.size = base.resolvedDataType.Size; base.dataTypeId = ((DataType)base.resolvedDataType).DataTypeId; base.category = base.resolvedDataType.Category; base.typeName = base.resolvedDataType.Name; } else { base.size = !base.IsBitType ? type.ElementSize : 1; base.dataTypeId = type.ElementTypeId; base.category = DataTypeCategory.Unknown; base.typeName = type.ElementTypeName; } if (!oversampleElement) { this.calcAccess(parent, elementType, ArrayType.GetElementOffset(indices, (IArrayType)((DataType)parent.DataType).ResolveType(DataTypeResolveStrategy.AliasReference)), base.flags, elementType.Flags, out this.indexGroup, out this.indexOffset); } else { this.indexGroup = 0xf019; this.indexOffset = 0; } base.SetContextMask(((IContextMaskProvider)parent).ContextMask); DataTypeCategory category = base.category; }
internal Symbol(Member member, ISymbol parent) { this.accessRights = SymbolAccessRights.All; if (member == null) { throw new ArgumentNullException("member"); } if (parent == null) { throw new ArgumentNullException("parent"); } this.factoryServices = ((ISymbolFactoryServicesProvider)parent).FactoryServices; this.parent = parent; base.Bind(((IBinderProvider)parent).Binder); string instanceName = member.InstanceName; base.instanceName = instanceName; this.instancePath = parent.InstancePath + "." + instanceName; base.resolvedDataType = (DataType)member.DataType; base.flags = this.getSymbolFlags(parent, member); this._memberFlags = member.MemberFlags; this.staticAddress = parent.IsStatic || this._memberFlags.HasFlag(AdsDataTypeFlags.None | AdsDataTypeFlags.Static); base.attributes = (member.Attributes.Count <= 0) ? null : new TypeAttributeCollection(member.Attributes); base.comment = member.Comment; if (base.resolvedDataType != null) { base.size = base.resolvedDataType.Size; base.dataTypeId = ((DataType)base.resolvedDataType).DataTypeId; base.category = base.resolvedDataType.Category; base.typeName = base.resolvedDataType.Name; } else { base.size = member.Size; base.dataTypeId = member.DataTypeId; base.category = member.Category; base.typeName = member.TypeName; } this.calcAccess(parent, member, out this.indexGroup, out this.indexOffset); base.SetContextMask(((IContextMaskProvider)parent).ContextMask); DataTypeCategory category = base.category; }
public InsufficientAccessRights(IValueSymbol symbol, SymbolAccessRights requested) : base($"The requested rights '{requested}' for symbol '{symbol.InstanceName}' are not sufficient (Current rights: {symbol.AccessRights})!", symbol) { }