예제 #1
0
        override public RMUD.MudObject GetObject(string Path)
        {
            Path = Path.Replace('\\', '/');

            String BasePath, InstanceName;

            SplitObjectName(Path, out BasePath, out InstanceName);

            if (!String.IsNullOrEmpty(InstanceName))
            {
                MudObject activeInstance = null;
                if (ActiveInstances.TryGetValue(Path, out activeInstance))
                {
                    return(activeInstance);
                }
                else
                {
                    return(CreateInstance(Path));
                }
            }
            else
            {
                MudObject r = null;

                if (NamedObjects.ContainsKey(BasePath))
                {
                    r = NamedObjects[BasePath];
                }
                else
                {
                    var typeName = BaseObjectName + "." + Path.Replace("/", ".");
                    var type     = SourceAssembly.GetType(typeName);
                    if (type == null)
                    {
                        return(null);
                    }
                    r = Activator.CreateInstance(type) as MudObject;
                    if (r != null)
                    {
                        r.Path  = Path;
                        r.State = ObjectState.Unitialized;
                        NamedObjects.Upsert(BasePath, r);
                    }
                }

                if (r != null && r.State == ObjectState.Unitialized)
                {
                    MudObject.InitializeObject(r);
                }

                return(r);
            }
        }
예제 #2
0
        override public MudObject GetObject(String Path)
        {
            Path = Path.Replace('\\', '/');

            String BasePath, InstanceName;

            SplitObjectName(Path, out BasePath, out InstanceName);

            if (!String.IsNullOrEmpty(InstanceName))
            {
                MudObject activeInstance = null;
                if (ActiveInstances.TryGetValue(Path, out activeInstance))
                {
                    return(activeInstance);
                }
                else
                {
                    return(CreateInstance(Path));
                }
            }
            else
            {
                MudObject r = null;

                if (NamedObjects.ContainsKey(BasePath))
                {
                    r = NamedObjects[BasePath];
                }
                else
                {
                    r = CompileObject(BasePath);
                    if (r != null)
                    {
                        NamedObjects.Upsert(BasePath, r);
                    }
                }

                if (r != null && r.State == ObjectState.Unitialized)
                {
                    Core.InitializeObject(r);
                }

                return(r);
            }
        }