예제 #1
0
        public GUISettings(IObjectData data) : base(data)
        {
            // prepare settings
            bool start          = Defaults.Start;
            int  resumeTryCount = Defaults.ResumeTryCount;
            int  resumeDelay    = Defaults.ResumeDelay;
            int  resumeInterval = Defaults.ResumeInterval;

            if (data != null)
            {
                // get settings from data
                start          = data.GetBooleanValue(SettingNames.Start, start);
                resumeTryCount = data.GetInt32Value(SettingNames.ResumeTryCount, resumeTryCount);
                resumeDelay    = data.GetInt32Value(SettingNames.ResumeDelay, resumeDelay);
                resumeInterval = data.GetInt32Value(SettingNames.ResumeInterval, resumeInterval);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.Start          = start;
                this.ResumeTryCount = resumeTryCount;
                this.ResumeDelay    = resumeDelay;
                this.ResumeInterval = resumeInterval;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
예제 #2
0
        protected virtual CommandSettings CreateExecutingSettings(IDictionary <string, string> options, IList <string> normalArguments)
        {
            // argument checks
            Debug.Assert(options != null);
            Debug.Assert(normalArguments != null);

            // create base settings
            IObjectData     settingsData = GetBaseSettings(options);
            CommandSettings settings     = this.ComponentFactory.CreateCommandSettings(settingsData);

            // load base settings
            LoadBaseSettings(settings);

            // consolidate the settings and command line options
            foreach (KeyValuePair <string, string> option in options)
            {
                if (HandleOption(option.Key, option.Value, settings) == false)
                {
                    string message = string.Format(Resources.CommandBase_Message_InvalidOption, option.Key);
                    throw new Exception(message);
                }
            }
            foreach (string arg in normalArguments)
            {
                if (HandleArgument(arg, settings) == false)
                {
                    string message = string.Format(Resources.CommandBase_Message_InvalidArgument, arg);
                    throw new Exception(message);
                }
            }

            return(settings);
        }
예제 #3
0
    public void CreateSlotItemAsChildOfExistingSlot(GameObject item)
    {
        GameObject  newSlotItem = Instantiate(slotItem, transform, false);
        Component   comp        = item.GetComponent <SlotObjectContainer>().obj.GetComponent(typeof(IObjectData));
        IObjectData objectData  = comp as IObjectData;
        string      uiText;

        if (objectData.count() == 1)
        {
            uiText = objectData.objectName();
        }
        else
        {
            uiText = objectData.objectName() + " x" + objectData.count();
        }
        newSlotItem.GetComponent <SlotObjectContainer> ().obj = item.GetComponent <SlotObjectContainer>().obj;
        newSlotItem.GetComponent <Text> ().text = uiText;

        QuestTriggerWrapper questTriggerWrapper = newSlotItem.GetComponent <SlotObjectContainer> ().obj.GetComponent <QuestTriggerWrapper>();

        if (questTriggerWrapper != null)
        {
            QuestTrigger trigger = questTriggerWrapper.questTrigger;
            if (trigger != null)
            {
                Debug.Log("Process Quest Trigger.");
                GameObject.Find("QuestManager").GetComponent <QuestManager> ().ProcessQuestTrigger(trigger);
            }
        }

        Destroy(item);
    }
예제 #4
0
        public override T[]? GetArrayElementValues <T>(ulong objRef, int count)
        {
            ulong          address       = GetArrayElementAddress(objRef, 0);
            ClrType?       componentType = ComponentType;
            ClrElementType cet;

            if (componentType != null)
            {
                cet = componentType.ElementType;
            }
            else
            {
                // Slow path, we need to get the element type of the array.
                IObjectData data = Helpers.GetObjectData(objRef);
                if (data is null)
                {
                    return(null);
                }

                cet = data.ElementType;
            }

            if (cet == ClrElementType.Unknown)
            {
                return(null);
            }

            if (address == 0)
            {
                return(null);
            }

            return(ValueReader.GetValuesFromAddress <T>(DataReader, address, count));
        }
예제 #5
0
    // I decided that i didn't want to support the drag and drop on chests to create new items.

    /*
     * public void OnDrop (PointerEventData eventData) {
     *  if (DragHandler.itemBeingDragged == null) {
     *      return;
     *  }
     *
     *  GameObject containerSlot = null;
     *  if (DragHandler.itemBeingDragged.transform.parent.GetComponent<ContainerSlot>()) {
     *      containerSlot = DragHandler.startParent.gameObject;
     *  }
     *
     *  CreateSlotWithItem (DragHandler.itemBeingDragged.GetComponent<SlotObjectContainer>().obj);
     *
     *  if (containerSlot) {
     *      Destroy (containerSlot);
     *  }
     *  DestroyImmediate (DragHandler.itemBeingDragged.transform.gameObject);
     *
     *  DragHandler.itemBeingDragged = null;
     * }
     */

    public void CreateSlotWithItem(GameObject Item)
    {
        GameObject slot     = Instantiate(Slot, transform.GetChild(0).transform.GetChild(0), false);
        GameObject slotItem = Instantiate(ContainerSlotItem, slot.transform, false);

        slotItem.GetComponent <SlotObjectContainer> ().obj = Item;

        GameObject  item       = slotItem.GetComponent <SlotObjectContainer> ().obj;
        Component   objectData = item.GetComponent(typeof(IObjectData));
        IObjectData data       = objectData as IObjectData;

        slotItem.GetComponent <Text> ().text = data.objectName();

        if (data.count() != 1)
        {
            slotItem.GetComponent <Text> ().text += " x" + data.count();
        }

        // Process Quest UnTrigger.
        QuestTriggerWrapper questTriggerWrapper = item.GetComponent <QuestTriggerWrapper> ();

        if (questTriggerWrapper != null)
        {
            QuestTrigger trigger = questTriggerWrapper.questTrigger;
            if (trigger != null)
            {
                GameObject.Find("QuestManager").GetComponent <QuestManager> ().ProcessQuestUnTrigger(trigger);
            }
        }
    }
예제 #6
0
        ///////////////////////////////////////////////////////////////////////

        public ObjectData(
            IObjectData objectData
            )
            : this()
        {
            if (objectData != null)
            {
                name                    = objectData.Name;
                group                   = objectData.Group;
                description             = objectData.Description;
                clientData              = objectData.ClientData;
                type                    = objectData.Type;
                objectFlags             = objectData.ObjectFlags;
                referenceCount          = objectData.ReferenceCount;
                temporaryReferenceCount = objectData.TemporaryReferenceCount;

#if NATIVE && TCL
                interpName = objectData.InterpName;
#endif

#if DEBUGGER && DEBUGGER_ARGUMENTS
                executeArguments = objectData.ExecuteArguments;
#endif

                token = objectData.Token;
            }
        }
예제 #7
0
        protected override GUISettings CreateGUISettings(IObjectData data)
        {
            // argument checks
            // data can be null

            return(new GUIForWindowsGUISettings(data));
        }
예제 #8
0
        public override RcwData GetRCWData(ulong obj)
        {
            // Most types can't possibly be RCWs.
            if (_notRCW)
            {
                return(null);
            }

            // The dac cannot report this information prior to v4.5.
            if (DesktopHeap.DesktopRuntime.CLRVersion != DesktopVersion.v45)
            {
                _notRCW = true;
                return(null);
            }

            DesktopRCWData result = null;
            IObjectData    data   = DesktopHeap.GetObjectData(obj);

            if (data != null && data.RCW != 0)
            {
                IRCWData rcw = DesktopHeap.DesktopRuntime.GetRCWData(data.RCW);
                if (rcw != null)
                {
                    result = new DesktopRCWData(DesktopHeap, data.RCW, rcw);
                }
            }
            else if (!_checkedIfIsRCW)     // If the first time fails, we assume that all instances of this type can't be RCWs.
            {
                _notRCW = true;            // TODO FIX NOW review.  We really want to simply ask the runtime...
            }

            _checkedIfIsRCW = true;
            return(result);
        }
예제 #9
0
        public override ulong GetArrayElementAddress(ulong objRef, int index)
        {
            if (_baseArrayOffset == 0)
            {
                var componentType = ComponentType;

                IObjectData data = DesktopHeap.DesktopRuntime.GetObjectData(objRef);
                if (data != null)
                {
                    _baseArrayOffset = (int)(data.DataPointer - objRef);
                    Debug.Assert(_baseArrayOffset >= 0);
                }
                else if (componentType != null)
                {
                    if (!componentType.IsObjectReference || !Heap.Runtime.HasArrayComponentMethodTables)
                    {
                        _baseArrayOffset = IntPtr.Size * 2;
                    }
                    else
                    {
                        _baseArrayOffset = IntPtr.Size * 3;
                    }
                }
                else
                {
                    return(0);
                }
            }

            return(objRef + (ulong)(_baseArrayOffset + index * _componentSize));
        }
    private void Helper(IObjectData objData, UITreeData parUiTree)
    {
        var curUiTree = new UITreeData(objData.Name, objData.EntityLabel);

        if (objData is IElementData)
        {
            IElementData eleData        = objData as IElementData;
            var          typeUiTreeData = parUiTree.FindChildren(eleData.TypeName);
            if (typeUiTreeData == default)
            {
                typeUiTreeData = new UITreeData(eleData.TypeName, eleData.ProductGeoData.typeId);
                parUiTree.AddChild(typeUiTreeData);
            }
            var curEleUiTreeData = new UITreeData(objData.Name, objData.EntityLabel);
            typeUiTreeData.AddChild(curEleUiTreeData);
            foreach (var decEle in objData.RelatedObjects)
            {
                curEleUiTreeData.AddChild(new UITreeData(decEle.Name, decEle.EntityLabel));
            }
            return;
        }
        parUiTree.AddChild(curUiTree);
        foreach (var p in objData.RelatedObjects)
        {
            Helper(p, curUiTree);
        }
    }
예제 #11
0
        public override CcwData GetCCWData(ulong obj)
        {
            if (_notCCW)
            {
                return(null);
            }

            // The dac cannot report this information prior to v4.5.
            if (DesktopHeap.DesktopRuntime.CLRVersion != DesktopVersion.v45)
            {
                return(null);
            }

            DesktopCCWData result = null;
            IObjectData    data   = DesktopHeap.GetObjectData(obj);

            if (data != null && data.CCW != 0)
            {
                ICCWData ccw = DesktopHeap.DesktopRuntime.GetCCWData(data.CCW);
                if (ccw != null)
                {
                    result = new DesktopCCWData(DesktopHeap, data.CCW, ccw);
                }
            }
            else if (!_checkedIfIsCCW)
            {
                _notCCW = true;
            }

            _checkedIfIsCCW = true;
            return(result);
        }
예제 #12
0
        public static IObjectDataValue CreateObjectValue(IObjectData objectData, IObjectData value)
        {
            // argument checks
            Debug.Assert(objectData != null);

            return(objectData.CreateValue(value));
        }
예제 #13
0
        public static IObjectDataValue CreateObjectValue <T>(this IObjectData data, T value, Action <T, IObjectData, bool> saveObject, string name, bool overwrite, bool omitDefault)
        {
            // argument checks
            Debug.Assert(data != null);
            Debug.Assert(saveObject != null);
            Debug.Assert(name != null || overwrite == false);

            IObjectData objectData = null;

            if (value != null)
            {
                // get IObjectData into which the value saves its contents
                if (overwrite)
                {
                    // overwirte mode
                    objectData = data.GetObjectValue(name, defaultValue: null);
                }
                if (objectData == null)
                {
                    // create a empty IObjectData
                    objectData = data.CreateObject();
                }

                // save the value's contents
                saveObject(value, objectData, omitDefault);
            }

            return(data.CreateValue(objectData));
        }
예제 #14
0
        public static IObjectDataValue CreateArrayValue(IObjectData objectData, IEnumerable <IObjectDataValue> value)
        {
            // argument checks
            Debug.Assert(objectData != null);

            return(objectData.CreateValue(value));
        }
        protected virtual MainWindowSettings CreateMainWindowSettings(IObjectData data)
        {
            // argument checks
            // data can be null

            return(new MainWindowSettings(data));
        }
        public GUIForWindowsGUISettings(IObjectData data) : base(data)
        {
            // prepare settings
            bool chaseLastLog             = Defaults.ChaseLastLog;
            MainWindowSettings mainWindow = null;

            if (data != null)
            {
                // get settings from data
                chaseLastLog = data.GetBooleanValue(SettingNames.ChaseLastLog, chaseLastLog);
                mainWindow   = data.GetObjectValue(SettingNames.MainWindow, mainWindow, this.CreateMainWindowSettings);
            }
            if (mainWindow == null)
            {
                mainWindow = CreateMainWindowSettings(null);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.ChaseLastLog = chaseLastLog;
                this.mainWindow   = mainWindow;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
예제 #17
0
        /// <summary>
        /// Try to get stored value data for an instance
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool TryGetObjectData(object obj, out IObjectData data)
        {
            if (ObjectValueData.TryGetValue(obj, out data))
            {
                if (ReferenceEquals(data.Owner, obj))
                {
                    return(true);
                }
            }
            // Not found - must check everything in the DB since GetHashCode isn't guaranteeed to be unique or to stay the same
            // There are probably ways to optimize this, in fact, it may not even be necessary, but it should be pretty
            // inexpensive unless dealing with huge numbers of objects

            foreach (KeyValuePair <object, IObjectData> kvps in ObjectValueData)
            {
                if (ReferenceEquals(kvps.Value.Owner, obj))
                {
                    data = kvps.Value;
                    return(true);
                }
                else if (kvps.Value.Orphaned)
                {
                    RemoveFromDict(kvps.Key);
                }
            }
            data = null;
            return(false);
        }
예제 #18
0
        public override ulong GetArrayElementAddress(ulong objRef, int index)
        {
            // todo: remove?
            if (_baseArrayOffset == 0)
            {
                ClrType?componentType = ComponentType;

                IObjectData data = Helpers.GetObjectData(objRef);
                if (data != null)
                {
                    _baseArrayOffset = (int)(data.DataPointer - objRef);
                    DebugOnly.Assert(_baseArrayOffset >= 0);
                }
                else if (componentType != null)
                {
                    if (!componentType.IsObjectReference)
                    {
                        _baseArrayOffset = IntPtr.Size * 2;
                    }
                }
                else
                {
                    return(0);
                }
            }

            return(objRef + (ulong)(_baseArrayOffset + index * ComponentSize));
        }
        // objects
        public ICmisObject ConvertObject(IObjectData objectData, IOperationContext context)
        {
            if (objectData == null)
            {
                throw new ArgumentNullException("objectData");
            }

            IObjectType type = GetTypeFromObjectData(objectData);

            switch (objectData.BaseTypeId)
            {
            case BaseTypeId.CmisDocument:
                return(new Document(session, type, objectData, context));

            case BaseTypeId.CmisFolder:
                return(new Folder(session, type, objectData, context));

            case BaseTypeId.CmisPolicy:
                return(new Policy(session, type, objectData, context));

            case BaseTypeId.CmisRelationship:
                return(new Relationship(session, type, objectData, context));

            default:
                throw new CmisRuntimeException("Unsupported type: " + objectData.BaseTypeId.ToString());
            }
        }
예제 #20
0
        protected virtual ActualProxySettings CreateActualProxySettings(IObjectData data)
        {
            // argument checks
            // data can be null

            return((data == null)? null: new ActualProxySettings(data));
        }
예제 #21
0
        public SystemSettingsSwitcherSettings(IObjectData data) : base(data)
        {
            // prepare settings
            bool enableSystemSettingsSwitch = Defaults.EnableSystemSettingsSwitch;
            ActualProxySettings actualProxy = null;

            if (data != null)
            {
                // get settings from data
                enableSystemSettingsSwitch = data.GetBooleanValue(SettingNames.EnableSystemSettingsSwitch, enableSystemSettingsSwitch);
                // Note that ActualProxy should not be empty but null if the settings do not exist.
                actualProxy = data.GetObjectValue(SettingNames.ActualProxy, actualProxy, this.CreateActualProxySettings);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.EnableSystemSettingsSwitch = enableSystemSettingsSwitch;
                this.ActualProxy = actualProxy;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
예제 #22
0
        protected static ListenerSettings CreateListenerSettings(IObjectData data)
        {
            // argument checks
            Debug.Assert(data != null);

            return(new ListenerSettings(data));
        }
예제 #23
0
        /// <summary>
        /// Constructor for objects.
        /// </summary>
        public AtomEntryWriter(IObjectData objectData, CmisVersion cmisVersion, IContentStream contentStream)
        {
            if (objectData == null || objectData.Properties == null)
            {
                throw new CmisInvalidArgumentException("Object and properties must not be null!");
            }

            if (contentStream != null && contentStream.MimeType == null)
            {
                throw new CmisInvalidArgumentException("Media type must be set if a stream is present!");
            }

            this.objectData    = objectData;
            this.cmisVersion   = cmisVersion;
            this.contentStream = contentStream;
            if (contentStream != null && contentStream.Stream != null)
            {
                // do we need buffering here?
                stream = contentStream.Stream;
            }
            else
            {
                stream = null;
            }
            this.typeDef    = null;
            this.bulkUpdate = null;
        }
예제 #24
0
        public ListenerSettings(IObjectData data) : base(data)
        {
            // prepare settings
            IPAddress address = Defaults.Address;
            int       port    = Defaults.Port;
            int       backlog = Defaults.Backlog;

            if (data != null)
            {
                // get settings from data
                address = data.GetValue(SettingNames.Address, address, ExtractIPAddressValue);
                port    = data.GetInt32Value(SettingNames.Port, port);
                backlog = data.GetInt32Value(SettingNames.Backlog, backlog);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.Address = address;
                this.Port    = port;
                this.Backlog = backlog;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
예제 #25
0
        public CredentialSettings(IObjectData data) : base(data)
        {
            // prepare settings
            string endPoint = Defaults.EndPoint;
            string userName = Defaults.UserName;
            string password = string.Empty;
            CredentialPersistence persistence = Defaults.Persistence;
            bool enableAssumptionMode         = Defaults.EnableAssumptionMode;

            if (data != null)
            {
                // get settings from data
                endPoint             = data.GetStringValue(SettingNames.EndPoint, endPoint);
                userName             = data.GetStringValue(SettingNames.UserName, userName);
                password             = data.GetValue(SettingNames.ProtectedPassword, password, ExtractPasswordValue);
                persistence          = (CredentialPersistence)data.GetEnumValue(SettingNames.Persistence, persistence, typeof(CredentialPersistence));
                enableAssumptionMode = data.GetBooleanValue(SettingNames.EnableAssumptionMode, enableAssumptionMode);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.EndPoint             = endPoint;
                this.UserName             = userName;
                this.Password             = password;
                this.Persistence          = persistence;
                this.EnableAssumptionMode = enableAssumptionMode;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
예제 #26
0
        protected virtual GUISettings CreateGUISettings(IObjectData data)
        {
            // argument checks
            // data can be null

            return(new GUISettings(data));
        }
예제 #27
0
        protected virtual CredentialSettings CreateCredentialSettings(IObjectData data)
        {
            // argument checks
            // data can be null

            return(new CredentialSettings(data));
        }
예제 #28
0
        public ProxySettings(IObjectData data) : base(data)
        {
            // prepare settings
            ListenerSettings mainListener = null;
            IEnumerable <ListenerSettings> additionalListeners = null;
            int retryCount = Defaults.RetryCount;

            if (data != null)
            {
                // get settings from data
                mainListener        = data.GetObjectValue(SettingNames.MainListener, mainListener, CreateListenerSettings);
                additionalListeners = data.GetObjectArrayValue(SettingNames.AdditionalListeners, additionalListeners, CreateListenerSettings);
                retryCount          = data.GetInt32Value(SettingNames.RetryCount, retryCount);
            }
            if (mainListener == null)
            {
                mainListener = Defaults.CreateDefaultMainListener();
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.MainListener        = mainListener;
                this.AdditionalListeners = additionalListeners;
                this.RetryCount          = retryCount;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
예제 #29
0
파일: EventData.cs 프로젝트: saneman1/IQMap
 public ObjectInfo(IQEventType eventType,IDbContext queryController, IObjectData data, IClassInfo info, object obj)
 {
     EventType = eventType;
     QueryController = queryController;
     ObjectData = data;
     ClassInfo = info;
     Source = obj;
 }
예제 #30
0
        public static IObjectDataValue CreatePasswordValue(IObjectData data, string value)
        {
            // argument checks
            Debug.Assert(data != null);

            // create password value
            return(data.CreateValue(string.IsNullOrEmpty(value) ? string.Empty : ProtectPassword(value)));
        }
예제 #31
0
		public void SaveToObjectData(IObjectData data, bool omitDefault = false) {
			// argument checks
			if (data == null) {
				throw new ArgumentNullException(nameof(data));
			}

			SaveTo(data, omitDefault);
		}
예제 #32
0
 public Relationship(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
 {
     Initialize(session, objectType, objectData, context);
 }
예제 #33
0
        public QueryResult(ISession session, IObjectData objectData)
        {
            if (objectData != null)
            {
                IObjectFactory of = session.ObjectFactory;

                // handle properties
                if (objectData.Properties != null)
                {
                    Properties = new List<IPropertyData>();
                    propertiesById = new Dictionary<string, IPropertyData>();
                    propertiesByQueryName = new Dictionary<string, IPropertyData>();

                    IList<IPropertyData> queryProperties = of.ConvertQueryProperties(objectData.Properties);

                    foreach (IPropertyData property in queryProperties)
                    {
                        Properties.Add(property);
                        if (property.Id != null)
                        {
                            propertiesById[property.Id] = property;
                        }
                        if (property.QueryName != null)
                        {
                            propertiesByQueryName[property.QueryName] = property;
                        }
                    }
                }

                // handle allowable actions
                AllowableActions = objectData.AllowableActions;

                // handle relationships
                if (objectData.Relationships != null)
                {
                    Relationships = new List<IRelationship>();
                    foreach (IObjectData rod in objectData.Relationships)
                    {
                        IRelationship relationship = of.ConvertObject(rod, session.DefaultContext) as IRelationship;
                        if (relationship != null)
                        {
                            Relationships.Add(relationship);
                        }
                    }
                }

                // handle renditions
                if (objectData.Renditions != null)
                {
                    Renditions = new List<IRendition>();
                    foreach (IRenditionData rd in objectData.Renditions)
                    {
                        Renditions.Add(of.ConvertRendition(null, rd));
                    }
                }
            }
        }
예제 #34
0
 public Document(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
 {
     Initialize(session, objectType, objectData, context);
 }
예제 #35
0
        protected void Initialize(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            if (objectType == null)
            {
                throw new ArgumentNullException("objectType");
            }

            if (objectType.PropertyDefinitions == null || objectType.PropertyDefinitions.Count < 9)
            {
                // there must be at least the 9 standard properties that all objects have
                throw new ArgumentException("Object type must have property defintions!");
            }

            this.Session = session;
            this.objectType = objectType;
            this.extensions = new Dictionary<ExtensionLevel, IList<ICmisExtensionElement>>();
            this.CreationContext = new OperationContext(context);
            this.RefreshTimestamp = DateTime.UtcNow;

            IObjectFactory of = Session.ObjectFactory;

            if (objectData != null)
            {
                // handle properties
                if (objectData.Properties != null)
                {
                    properties = of.ConvertProperties(objectType, objectData.Properties);
                    extensions[ExtensionLevel.Properties] = objectData.Properties.Extensions;
                }

                // handle allowable actions
                if (objectData.AllowableActions != null)
                {
                    allowableActions = objectData.AllowableActions;
                    extensions[ExtensionLevel.AllowableActions] = objectData.AllowableActions.Extensions;
                }

                // handle renditions
                if (objectData.Renditions != null)
                {
                    renditions = new List<IRendition>();
                    foreach (IRenditionData rd in objectData.Renditions)
                    {
                        renditions.Add(of.ConvertRendition(Id, rd));
                    }
                }

                // handle ACL
                if (objectData.Acl != null)
                {
                    acl = objectData.Acl;
                    extensions[ExtensionLevel.Acl] = objectData.Acl.Extensions;
                }

                // handle policies
                if (objectData.PolicyIds != null && objectData.PolicyIds.PolicyIds != null)
                {
                    policies = new List<IPolicy>();
                    foreach (string pid in objectData.PolicyIds.PolicyIds)
                    {
                        IPolicy policy = Session.GetObject(Session.CreateObjectId(pid)) as IPolicy;
                        if (policy != null)
                        {
                            policies.Add(policy);
                        }
                    }
                    extensions[ExtensionLevel.Policies] = objectData.PolicyIds.Extensions;
                }

                // handle relationships
                if (objectData.Relationships != null)
                {
                    relationships = new List<IRelationship>();
                    foreach (IObjectData rod in objectData.Relationships)
                    {
                        IRelationship relationship = of.ConvertObject(rod, CreationContext) as IRelationship;
                        if (relationship != null)
                        {
                            relationships.Add(relationship);
                        }
                    }
                }

                extensions[ExtensionLevel.Object] = objectData.Extensions;
            }
        }
예제 #36
0
        /// <summary>
        /// Try to get stored value data for an instance
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool TryGetObjectData(object obj, out IObjectData data)
        {
            if (ObjectValueData.TryGetValue(obj, out data))
            {
                if (ReferenceEquals(data.Owner, obj))
                {
                    return true;
                }
            }
            // Not found - must check everything in the DB since GetHashCode isn't guaranteeed to be unique or to stay the same
            // There are probably ways to optimize this, in fact, it may not even be necessary, but it should be pretty
            // inexpensive unless dealing with huge numbers of objects

            foreach (KeyValuePair<object, IObjectData> kvps in ObjectValueData)
            {
                if (ReferenceEquals(kvps.Value.Owner, obj))
                {
                    data = kvps.Value;
                    return true;
                }
                else if (kvps.Value.Orphaned)
                {
                    RemoveFromDict(kvps.Key);
                }
            }
            data = null;
            return false;
        }