コード例 #1
0
        public void InitializeUnconstructedInstance(object mixinTarget, InitializationSemantics initializationSemantics)
        {
            ArgumentUtility.CheckNotNull("mixinTarget", mixinTarget);
            ArgumentUtility.CheckType <IMixinTarget> ("mixinTarget", mixinTarget);

            _pipelineRegistry.DefaultPipeline.ReflectionService.PrepareExternalUninitializedObject(mixinTarget, initializationSemantics);
        }
コード例 #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;
        }
コード例 #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();
        }
コード例 #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;
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #9
0
        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)));
        }
コード例 #10
0
        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);
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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());
        }
コード例 #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);
        }
コード例 #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());
        }
コード例 #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));
        }
コード例 #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;
        }
コード例 #18
0
 object IList.this[int index]
 {
     get { return(this[index]); }
     set { this[index] = ArgumentUtility.CheckType <DomainObject> ("value", value); }
 }
コード例 #19
0
 public void Succeed_NotNull()
 {
     Assert.That(ArgumentUtility.CheckType("arg", "test", typeof(string)), Is.EqualTo("test"));
 }
コード例 #20
0
 public void Fail_ValueType()
 {
     ArgumentUtility.CheckType("arg", (object)DateTime.MinValue, typeof(int));
 }
コード例 #21
0
 public void Succeed_ReferenceTypeNull()
 {
     Assert.That(ArgumentUtility.CheckType("arg", (object)null, typeof(string)), Is.EqualTo(null));
 }
コード例 #22
0
 public void Succeed_NullableValueTypeNull()
 {
     Assert.That(ArgumentUtility.CheckType("arg", (object)null, typeof(int?)), Is.EqualTo(null));
 }
コード例 #23
0
 public void Fail_ValueTypeNull()
 {
     ArgumentUtility.CheckType("arg", (object)null, typeof(int));
 }
コード例 #24
0
 public void Fail_Type()
 {
     ArgumentUtility.CheckType("arg", 13, typeof(string));
 }
コード例 #25
0
 public void Succeed_ValueType()
 {
     Assert.That(ArgumentUtility.CheckType("arg", (object)1, typeof(int)), Is.EqualTo(1));
 }
コード例 #26
0
 public void Fail_Type()
 {
     ArgumentUtility.CheckType <string> ("arg", 13);
 }
コード例 #27
0
 public void Fail_ValueType()
 {
     ArgumentUtility.CheckType <int> ("arg", (object)null);
 }
コード例 #28
0
        public void Succeed_Null()
        {
            string result = ArgumentUtility.CheckType <string> ("arg", null);

            Assert.That(result, Is.EqualTo(null));
        }
コード例 #29
0
        public void Succeed_String()
        {
            string result = ArgumentUtility.CheckType <string> ("arg", "test");

            Assert.That(result, Is.EqualTo("test"));
        }
コード例 #30
0
        public void Succeed_BaseType()
        {
            string result = (string)ArgumentUtility.CheckType <object> ("arg", "test");

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