public void InitializeUnconstructedInstance(object mixinTarget, InitializationSemantics initializationSemantics)
        {
            ArgumentUtility.CheckNotNull("mixinTarget", mixinTarget);
            ArgumentUtility.CheckType <IMixinTarget> ("mixinTarget", mixinTarget);

            _pipelineRegistry.DefaultPipeline.ReflectionService.PrepareExternalUninitializedObject(mixinTarget, initializationSemantics);
        }
Ejemplo n.º 2
0
        public NamedArgumentDeclaration(FieldInfo fieldInfo, object value)
        {
            ArgumentUtility.CheckNotNull("fieldInfo", fieldInfo);
            ArgumentUtility.CheckType("value", value, fieldInfo.FieldType);

            if (fieldInfo.IsLiteral || fieldInfo.IsInitOnly)
            {
                var message = string.Format("Field '{0}' is not writable.", fieldInfo.Name);
                throw new ArgumentException(message, "fieldInfo");
            }

            if (!fieldInfo.IsPublic)
            {
                var message = string.Format("Field '{0}' is not public.", fieldInfo.Name);
                throw new ArgumentException(message, "fieldInfo");
            }

            if (fieldInfo.IsStatic)
            {
                var message = string.Format("Field '{0}' is not an instance field.", fieldInfo.Name);
                throw new ArgumentException(message, "fieldInfo");
            }

            _memberInfo = fieldInfo;
            _memberType = fieldInfo.FieldType;
            _value      = value;
        }
Ejemplo n.º 3
0
        public void SetValueWithoutTypeCheck(PropertyAccessor propertyAccessor, ClientTransaction transaction, object value)
        {
            ArgumentUtility.CheckNotNull("propertyAccessor", propertyAccessor);
            ArgumentUtility.CheckNotNull("transaction", transaction);
            var newRelatedObject = ArgumentUtility.CheckType <DomainObject> ("value", value);

            var endPointID = CreateRelationEndPointID(propertyAccessor);
            var endPoint   = (IObjectEndPoint)transaction.DataManager.GetRelationEndPointWithLazyLoad(endPointID);

            if (newRelatedObject != null && transaction.RootTransaction != newRelatedObject.RootTransaction)
            {
                var formattedMessage = String.Format(
                    "Property '{1}' of DomainObject '{2}' cannot be set to DomainObject '{0}'.",
                    newRelatedObject.ID,
                    endPoint.Definition.PropertyName,
                    endPoint.ObjectID);
                throw new ClientTransactionsDifferException(formattedMessage + " The objects do not belong to the same ClientTransaction.");
            }

            DomainObjectCheckUtility.EnsureNotDeleted(endPoint.GetDomainObjectReference(), endPoint.ClientTransaction);
            if (newRelatedObject != null)
            {
                DomainObjectCheckUtility.EnsureNotDeleted(newRelatedObject, endPoint.ClientTransaction);
                CheckNewRelatedObjectType(endPoint, newRelatedObject);
            }

            var setCommand = endPoint.CreateSetCommand(newRelatedObject);
            var bidirectionalModification = setCommand.ExpandToAllRelatedObjects();

            bidirectionalModification.NotifyAndPerform();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamedValue"/> class, setting the <see cref="Value"/> and <see cref="DataInfo"/> properties.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="streamedValueInfo">A <see cref="StreamedValueInfo"/> describing the value.</param>
        public StreamedValue(object value, StreamedValueInfo streamedValueInfo)
        {
            ArgumentUtility.CheckNotNull("streamedValueInfo", streamedValueInfo);
            ArgumentUtility.CheckType("value", value, streamedValueInfo.DataType);

            Value    = value;
            DataInfo = streamedValueInfo;
        }
Ejemplo n.º 5
0
        public static object InvokeNonPublicMethod(object target, Type definingType, string methodName, params object[] arguments)
        {
            ArgumentUtility.CheckNotNull("target", target);
            ArgumentUtility.CheckNotNull("definingType", definingType);
            ArgumentUtility.CheckType("target", target, definingType);
            ArgumentUtility.CheckNotNullOrEmpty("methodName", methodName);

            return(InvokeMethodInternal(target, definingType, BindingFlags.Instance | BindingFlags.NonPublic, methodName, arguments));
        }
Ejemplo n.º 6
0
        private string ConvertFromGuidToString(object nativeValue)
        {
            Guid?guid = ArgumentUtility.CheckType <Guid?> ("nativeValue", nativeValue);

            if (guid == null)
            {
                return(null);
            }
            return(guid.ToString());
        }
        public IEnumerable <ColumnValue> SplitValueForComparison(object value)
        {
            var objectID = ArgumentUtility.CheckType <ObjectID> ("value", value);

            CheckClassDefinition(objectID, "value");

            var innerValue = GetValueOrNull(objectID);

            return(_valueProperty.SplitValueForComparison(innerValue));
        }
Ejemplo n.º 8
0
        public FlattenedDeserializationInfo(object[] data)
        {
            ArgumentUtility.CheckNotNull("data", data);
            object[] objects = ArgumentUtility.CheckType <object[]> ("data[0]", data[0]);
            int[]    ints    = ArgumentUtility.CheckType <int[]> ("data[1]", data[1]);
            bool[]   bools   = ArgumentUtility.CheckType <bool[]> ("data[2]", data[2]);

            _objectReader = new FlattenedSerializationReader <object> (objects);
            _intReader    = new FlattenedSerializationReader <int> (ints);
            _boolReader   = new FlattenedSerializationReader <bool> (bools);
        }
        public IEnumerable <ColumnValue> SplitValue(object value)
        {
            var objectID = ArgumentUtility.CheckType <ObjectID> ("value", value);

            if (objectID == null)
            {
                return(_valueProperty.SplitValue(null).Concat(_classIDProperty.SplitValue(null)));
            }

            return(_valueProperty.SplitValue(objectID.Value).Concat(_classIDProperty.SplitValue(objectID.ClassID)));
        }
        private readonly DependencyDefinitionBase _aggregator;   // the outer dependency containing this dependency, if defined indirectly

        public DependencyDefinitionBase(RequirementDefinitionBase requirement, DependencyDefinitionBase aggregator)
        {
            ArgumentUtility.CheckNotNull("requirement", requirement);
            ArgumentUtility.CheckType("aggregator", aggregator, GetType());

            _requirement = requirement;
            _aggregator  = aggregator;

            _aggregatedDependencies = new UniqueDefinitionCollection <Type, DependencyDefinitionBase> (
                delegate(DependencyDefinitionBase d) { return(d.RequiredType.Type); },
                HasSameDepender);
        }
Ejemplo n.º 11
0
        private Guid?ConvertFromStringToGuid(object publicValue)
        {
            string stringValue = ArgumentUtility.CheckType <string> ("publicValue", publicValue);

            if (stringValue == null)
            {
                return(null);
            }
            if (stringValue == string.Empty)
            {
                return(Guid.Empty);
            }
            return(new Guid(stringValue));
        }
Ejemplo n.º 12
0
        private string[] ConvertFromGuidListToStringArray(object nativeValue)
        {
            if (nativeValue == null)
            {
                return(null);
            }
            IList nativeValueList = ArgumentUtility.CheckType <IList> ("nativeValue", nativeValue);

            string[] publicValueList = new string[nativeValueList.Count];
            for (int i = 0; i < nativeValueList.Count; i++)
            {
                publicValueList[i] = ConvertFromGuidToString(nativeValueList[i]);
            }
            return(publicValueList);
        }
Ejemplo n.º 13
0
        public IBusinessObject[] Search(
            IBusinessObject referencingObject,
            IBusinessObjectReferenceProperty property,
            ISearchAvailableObjectsArguments searchArguments)
        {
            var referencingSecurityManagerObject = ArgumentUtility.CheckType <TReferencingObject> ("referencingObject", referencingObject);

            ArgumentUtility.CheckNotNull("property", property);

            var queryFactory = GetQueryFactory(property);

            var securityManagerSearchArguments = CreateSearchArguments(searchArguments);

            return(CreateQuery(queryFactory, referencingSecurityManagerObject, property, securityManagerSearchArguments).ToArray());
        }
Ejemplo n.º 14
0
        private IList ConvertFromStringListToGuidList(object publicValue)
        {
            if (publicValue == null)
            {
                return(null);
            }
            IList publicValueList = ArgumentUtility.CheckType <IList> ("publicValue", publicValue);
            IList nativeValueList = ListInfo.CreateList(publicValueList.Count);

            for (int i = 0; i < publicValueList.Count; i++)
            {
                nativeValueList[i] = ConvertFromStringToGuid(publicValueList[i]);
            }
            return(nativeValueList);
        }
Ejemplo n.º 15
0
        public IBusinessObject[] Search(
            IBusinessObject referencingObject,
            IBusinessObjectReferenceProperty property,
            ISearchAvailableObjectsArguments searchArguments)
        {
            ArgumentUtility.CheckNotNull("property", property);
            var rolePropertiesSearchArguments = ArgumentUtility.CheckType <RolePropertiesSearchArguments> ("searchArguments", searchArguments);

            if (!SupportsProperty(property))
            {
                throw new ArgumentException(
                          string.Format("The property '{0}' is not supported by the '{1}' type.", property.Identifier, GetType().FullName));
            }

            var positions         = GetPositions(rolePropertiesSearchArguments);
            var filteredPositions = FilterByAccess(positions, SecurityManagerAccessTypes.AssignRole);

            return(filteredPositions.ToArray());
        }
Ejemplo n.º 16
0
        private SecurityManagerSearchArguments CreateSearchArguments(ISearchAvailableObjectsArguments searchArguments)
        {
            if (searchArguments == null)
            {
                return(new SecurityManagerSearchArguments(null, null, null));
            }

            var defaultSearchArguments = searchArguments as DefaultSearchArguments;

            if (defaultSearchArguments != null)
            {
                if (string.IsNullOrEmpty(defaultSearchArguments.SearchStatement))
                {
                    return(new SecurityManagerSearchArguments(null, null, null));
                }

                var tenantHandle = ObjectID.Parse(defaultSearchArguments.SearchStatement).GetHandle <Tenant>();
                return(new SecurityManagerSearchArguments(new TenantConstraint(tenantHandle), null, null));
            }

            return(ArgumentUtility.CheckType <SecurityManagerSearchArguments> ("searchArguments", searchArguments));
        }
Ejemplo n.º 17
0
        public NamedArgumentDeclaration(PropertyInfo propertyInfo, object value)
        {
            ArgumentUtility.CheckNotNull("propertyInfo", propertyInfo);
            ArgumentUtility.CheckType("value", value, propertyInfo.PropertyType);

            var setMethod = propertyInfo.GetSetMethod();

            if (setMethod == null)
            {
                var message = string.Format("Property '{0}' has no public setter.", propertyInfo.Name);
                throw new ArgumentException(message, "propertyInfo");
            }

            if (setMethod.IsStatic)
            {
                var message = string.Format("Property '{0}' is not an instance property.", propertyInfo.Name);
                throw new ArgumentException(message, "propertyInfo");
            }

            _memberInfo = propertyInfo;
            _memberType = propertyInfo.PropertyType;
            _value      = value;
        }
 object IList.this[int index]
 {
     get { return(this[index]); }
     set { this[index] = ArgumentUtility.CheckType <DomainObject> ("value", value); }
 }
Ejemplo n.º 19
0
 public void Succeed_NotNull()
 {
     Assert.That(ArgumentUtility.CheckType("arg", "test", typeof(string)), Is.EqualTo("test"));
 }
Ejemplo n.º 20
0
 public void Fail_ValueType()
 {
     ArgumentUtility.CheckType("arg", (object)DateTime.MinValue, typeof(int));
 }
Ejemplo n.º 21
0
 public void Succeed_ReferenceTypeNull()
 {
     Assert.That(ArgumentUtility.CheckType("arg", (object)null, typeof(string)), Is.EqualTo(null));
 }
Ejemplo n.º 22
0
 public void Succeed_NullableValueTypeNull()
 {
     Assert.That(ArgumentUtility.CheckType("arg", (object)null, typeof(int?)), Is.EqualTo(null));
 }
Ejemplo n.º 23
0
 public void Fail_ValueTypeNull()
 {
     ArgumentUtility.CheckType("arg", (object)null, typeof(int));
 }
Ejemplo n.º 24
0
 public void Fail_Type()
 {
     ArgumentUtility.CheckType("arg", 13, typeof(string));
 }
Ejemplo n.º 25
0
 public void Succeed_ValueType()
 {
     Assert.That(ArgumentUtility.CheckType("arg", (object)1, typeof(int)), Is.EqualTo(1));
 }
Ejemplo n.º 26
0
 public void Fail_Type()
 {
     ArgumentUtility.CheckType <string> ("arg", 13);
 }
Ejemplo n.º 27
0
 public void Fail_ValueType()
 {
     ArgumentUtility.CheckType <int> ("arg", (object)null);
 }
Ejemplo n.º 28
0
        public void Succeed_Null()
        {
            string result = ArgumentUtility.CheckType <string> ("arg", null);

            Assert.That(result, Is.EqualTo(null));
        }
Ejemplo n.º 29
0
        public void Succeed_String()
        {
            string result = ArgumentUtility.CheckType <string> ("arg", "test");

            Assert.That(result, Is.EqualTo("test"));
        }
Ejemplo n.º 30
0
        public void Succeed_BaseType()
        {
            string result = (string)ArgumentUtility.CheckType <object> ("arg", "test");

            Assert.That(result, Is.EqualTo("test"));
        }