コード例 #1
0
        /// <summary>
        /// Creates a new instance from the specified type.
        /// </summary>
        /// <typeparam name="T">The internal abstract type to cast the new instance to.</typeparam>
        /// <param name="type">The type exposed by the script.</param>
        /// <returns>
        /// A new instance from the specified type.
        /// </returns>
        public override T CreateInstance <T>(ExternalType type)
        {
            var scope = ((DLRType)type).Scope;
            var impl  = scope.GetVariable(type.Name);

            return((T)scope.Engine.Operations.CreateInstance(impl));
        }
コード例 #2
0
        private bool IsEditorType(ExternalType type)
        {
            if (type.IsAbstract)
            {
                return(false);
            }

            if (type.GenericParameters.Count > 0)
            {
                return(false);
            }

            if (!HasBaseType(type, "Serenity.Widget"))
            {
                return(false);
            }

            if (type.AssemblyName != null &&
                type.AssemblyName.StartsWith("Serenity."))
            {
                return(false);
            }

            return(GetAttribute(type, "Serenity.EditorAttribute", inherited: true) != null ||
                   GetAttribute(type, "Serenity.ElementAttribute", inherited: true) != null ||
                   GetAttribute(type, "Serenity.Decorators.editor", inherited: true) != null ||
                   GetAttribute(type, "Serenity.Decorators.element", inherited: true) != null);
        }
コード例 #3
0
        private void GenerateEditor(ExternalType type, string name)
        {
            cw.Indented("public partial class ");
            sb.Append(name);

            bool isLookupEditor = HasBaseType(type, "Serenity.LookupEditorBase`1");

            sb.AppendLine(isLookupEditor ?
                          " : LookupEditorBaseAttribute" : " : CustomEditorAttribute");

            cw.InBrace(delegate
            {
                cw.Indented("public const string Key = \"");
                sb.Append(type.FullName);
                sb.AppendLine("\";");
                sb.AppendLine();

                cw.Indented("public ");
                sb.Append(name);
                sb.AppendLine("()");
                cw.IndentedLine("    : base(Key)");
                cw.IndentedLine("{");
                cw.IndentedLine("}");

                GenerateOptionMembers(type,
                                      skip: isLookupEditor?lookupEditorBaseOptions: null,
                                      isWidget: true);
            });
        }
コード例 #4
0
            public static LinkableComponentV1Base CreateWrappedComponent(ExternalType component, IEnumerable<Argument1> arguments)
            {
                var ns = Omi.Component.NamespaceOpenMIv1;

                var omi = new XElement(
                    ns + "LinkableComponent",
                    new XAttribute("Type", component.TypeName),
                    new XAttribute("Assembly", component.Url.LocalPath),
                    new XElement(ns + "Arguments", arguments.Select(a =>
                        new XElement(ns + "Argument",
                            new XAttribute("Key", a.Key),
                            new XAttribute("Value", a.Value))))
                );

                var version = Omi.Component.Version.One;

                if (arguments.Any(a => a.Key.Contains("FluidEarth") || a.Key.Contains("OpenWEB")))
                    version = Omi.Component.Version.OneFluidEarth;

                LinkableComponentV1Base c = null;

                if (version == Omi.Component.Version.One)
                    c = new LinkableComponentV1OpenMI();
                else
                    c = new LinkableComponentV1FluidEarth();

                throw new NotImplementedException();

                // c.ArgumentV1Omi = ??;
            }
コード例 #5
0
        /// <summary>
        /// Return a list of the values to display in the grid
        /// </summary>
        /// <param name="context"></param>
        /// <returns>A list of values the user can choose from</returns>
        public override StandardValuesCollection GetStandardValues
            (System.ComponentModel.ITypeDescriptorContext context)
        {
            // Try to get a store from the current context
            // "context.Instance"  returns the element(s) that
            // are currently selected i.e. whose values are being
            // shown in the property grid.
            // Note that the user could have selected multiple objects,
            // in which case context.Instance will be an array.
            Store store = GetStore(context.Instance);

            ColumnAttribute attr = (ColumnAttribute)context.Instance;

            ModelRoot root = attr.DataGrid.ModelRoot;

            List <string> values = new List <string>();

            values.AddRange(System.Enum.GetNames(typeof(Types)));

            if (store != null)
            {
                foreach (ModelType type in root.Types)
                {
                    if (type is ExternalType)
                    {
                        ExternalType typeEnum = type as ExternalType;
                        values.Add(typeEnum.Name);
                    }
                }
            }

            values.Add("");
            return(new StandardValuesCollection(values));
        }
        private void _mnuAdd_Click(object sender, EventArgs e)
        {
            try
            {
                ExternalType externalType = (ExternalType)((ToolStripMenuItem)sender).Tag;
                IExternal    external     = externalType.CreateExternal();

                IExternalPropertiesComponent component = externalType.CreateExternalPropertiesComponent();
                component.Load(external);

                SimpleComponentContainer container = new SimpleComponentContainer(component);
                if (_component.DesktopWindow.ShowDialogBox(container, Resources.TitleNewExternal) == DialogBoxAction.Ok)
                {
                    component.Update(external);
                    _component.Externals.Add(external);
                    ListViewItem lvi = CreateItem(external);
                    _listExternals.Items.Add(lvi);
                    lvi.Selected = true;
                    _component.FlagModified();
                }
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Error, ex, "An error occured while adding an external application definition.");
                MessageBox.Show(this, Resources.MessageErrorAddingExternal);
            }
        }
コード例 #7
0
    public ExternalTypeReference(int i, string g, ExternalType rt)
    {
        file_id = i;
        guid    = g;

        resolved_type = rt;
    }
コード例 #8
0
 public IEnumerable <ExternalType> GetExternalTypes()
 {
     return(GetAssemblyDefinition()
            .GetTypes()
            .Skip(t => t.IsSpecial())
            .Convert(t => ExternalType.CreateExternalType(t, this)));
 }
        public ExternalsConfigurationComponentControl(ExternalsConfigurationComponent component)
        {
            InitializeComponent();

            _component = component;

            SortedList <string, ExternalType> externalTypes  = new SortedList <string, ExternalType>();
            ExternalFactoryExtensionPoint     extensionPoint = new ExternalFactoryExtensionPoint();

            foreach (IExternalFactory externalFactory in extensionPoint.CreateExtensions())
            {
                ExternalType externalType = new ExternalType(externalFactory);
                externalTypes.Add(externalType.ToString(), externalType);
            }
            _externalTypes = externalTypes.Values;

            foreach (ExternalType externalType in _externalTypes)
            {
                ToolStripMenuItem item = new ToolStripMenuItem(externalType.ToString());
                item.Tag    = externalType;
                item.Click += _mnuAdd_Click;
                _mnuExternalTypes.Items.Add(item);
            }

            ResetExternalList();
        }
コード例 #10
0
        private bool IsEditorType(ExternalType type)
        {
            if (type.IsAbstract == true)
            {
                return(false);
            }

            if (type.GenericParameters?.Count > 0)
            {
                return(false);
            }

            if (!HasBaseType(type, "Serenity.Widget") &&
                !HasBaseType(type, "Serenity.Widget<any>"))
            {
                return(false);
            }

            return
                (GetAttribute(type, "Serenity.EditorAttribute", inherited: true) != null ||
                 GetAttribute(type, "Serenity.ElementAttribute", inherited: true) != null ||
                 GetAttribute(type, "Serenity.Decorators.registerEditor", inherited: true) != null ||
                 GetAttribute(type, "Serenity.Decorators.editor", inherited: true) != null ||
                 GetAttribute(type, "Serenity.Decorators.element", inherited: true) != null ||
                 HasBaseType(type, "Serenity.Extensions.GridEditorBase") ||
                 HasBaseType(type, "Serenity.LookupEditorBase"));
        }
コード例 #11
0
		public ExternalsConfigurationComponentControl(ExternalsConfigurationComponent component)
		{
			InitializeComponent();

			_component = component;

			SortedList<string, ExternalType> externalTypes = new SortedList<string, ExternalType>();
			ExternalFactoryExtensionPoint extensionPoint = new ExternalFactoryExtensionPoint();
			foreach (IExternalFactory externalFactory in extensionPoint.CreateExtensions())
			{
				ExternalType externalType = new ExternalType(externalFactory);
				externalTypes.Add(externalType.ToString(), externalType);
			}
			_externalTypes = externalTypes.Values;

			foreach (ExternalType externalType in _externalTypes)
			{
				ToolStripMenuItem item = new ToolStripMenuItem(externalType.ToString());
				item.Tag = externalType;
				item.Click += _mnuAdd_Click;
				_mnuExternalTypes.Items.Add(item);
			}

			ResetExternalList();
		}
コード例 #12
0
        public void DifferentTypeNotEqual()
        {
            var a = new ExternalType(new FunctionType());
            var b = new ExternalType(new TableType(0));

            Assert.That(a.Equals(b), Is.False);
        }
コード例 #13
0
        /// <summary>
        /// Gets the member of the specified type with the specified name, assuming there is only one.
        /// </summary>
        private IEntity GetMember(IType type, string name, EntityType entityType)
        {
            // For external types we can use GetMethod or GetProperty to optimize things a little
            ExternalType external = type as ExternalType;

            if (external != null)
            {
                if (entityType == EntityType.Property)
                {
                    return(TypeSystemServices.Map(
                               ((ExternalType)type).ActualType.GetProperty(name)));
                }

                else if (entityType == EntityType.Method)
                {
                    return(TypeSystemServices.Map(
                               ((ExternalType)type).ActualType.GetMethod(name)));
                }
            }

            // For constructed types which aren't external we can use the GenericMapping to
            // (maybe) optimize things a little
            if (type.ConstructedInfo != null)
            {
                return(((GenericConstructedType)type).GenericMapping.Map(
                           GetMember(type.ConstructedInfo.GenericDefinition, name, entityType)));
            }

            // For other cases we just scan through the members collection
            return(Array.Find <IEntity>(
                       type.GetMembers(),
                       delegate(IEntity e) {
                return entityType == e.EntityType && e.Name == name;
            }));
        }
コード例 #14
0
    public void ValidateFile(string filepath)
    {
        string text = File.ReadAllText(filepath);

        string modified_text = text.RegexReplace("m_Script\\s*:\\s*{\\s*fileID\\s*:\\s*([-0-9]+)\\s*,\\s*guid\\s*:\\s*([A-Za-z0-9_]+)\\s*,\\s*type\\s*:\\s*3\\s*}(.*?)(?=m_Script|$)", delegate(Match match) {
            string trailing = match.Groups[3].Value;
            ExternalTypeReference reference = new ExternalTypeReference(match.Groups[1].Value, match.Groups[2].Value);

            if (reference.IsValid())
            {
                ExternalType resolved = Resolve(reference, filepath + "\n\n" + trailing);

                if (resolved != null)
                {
                    ExternalTypeReference resolved_reference = resolved.GetReference();

                    if (resolved_reference.NotEqualsEX(reference))
                    {
                        return(resolved_reference.GetYAML() + trailing);
                    }
                }
            }

            return(match.Value);
        });

        if (modified_text != text)
        {
            File.WriteAllText(filepath, modified_text);
            Console.WriteLine(filepath + " was modified.");
        }
    }
コード例 #15
0
        public void TestResolveExternalXmlEntites(ExternalType externalType, string expected)
        {
            SvgDocument.ResolveExternalXmlEntites = externalType;

            Assert.That(new SvgDtdResolver().ResolveExternalXmlEntities, Is.EqualTo(externalType));

            var secretFilePath = MakeSecretFilePath();

            try
            {
                MakeSecretFile(secretFilePath);

                var maliciousSvg         = MakeMaliciousSvg(secretFilePath, SvgTextId);
                var maliciousSvgDocument = MakeMaliciousSvgDocument(maliciousSvg);

                var svgTextElement        = maliciousSvgDocument?.GetElementById(SvgTextId);
                var svgTextElementContent = svgTextElement?.Content;

                Assert.That(svgTextElementContent, Is.EqualTo(expected));
            }
            finally
            {
                DeleteSecretFile(secretFilePath);
            }
        }
コード例 #16
0
        private void GenerateEditor(ExternalType type, string name)
        {
            cw.Indented("public partial class ");
            sb.Append(name);

            bool isLookupEditor = HasBaseType(type, "Serenity.LookupEditorBase`1") ||
                HasBaseType(type, "Serenity.LookupEditorBase");

            sb.AppendLine(isLookupEditor ?
                " : LookupEditorBaseAttribute" : " : CustomEditorAttribute");

            cw.InBrace(delegate
            {
                cw.Indented("public const string Key = \"");
                sb.Append(type.FullName);
                sb.AppendLine("\";");
                sb.AppendLine();

                cw.Indented("public ");
                sb.Append(name);
                sb.AppendLine("()");
                cw.IndentedLine("    : base(Key)");
                cw.IndentedLine("{");
                cw.IndentedLine("}");

                GenerateOptionMembers(type, 
                    skip: isLookupEditor ? lookupEditorBaseOptions : null,
                    isWidget: true);
            });
        }
コード例 #17
0
        public void TestResolveExternalImages(ExternalType externalType, bool isNull)
        {
            SvgDocument.ResolveExternalImages = externalType;

            Assert.That(new SvgImage().ResolveExternalImages, Is.EqualTo(externalType));

            const string imageId = "ImageId";

            var sb = new StringBuilder();

            sb.Append(@"<?xml version=""1.0"" encoding=""utf-8""?>");
            sb.Append(@"<svg xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink"" height=""20"" width=""20"">");
            sb.Append($@"  <image id=""{imageId}"" height=""20"" width=""20"" xlink:href=""./W3CTestSuite/images/20x20.png"" />");
            sb.Append(@"</svg>");
            var svg = sb.ToString();

            var svgDoc = MakeMaliciousSvgDocument(svg);

            svgDoc.BaseUri = new Uri(Path.Combine(TestsRootPath, "dummy.svg"));

            var svgImage = svgDoc.GetElementById <SvgImage>(imageId);
            var image    = svgImage.GetImage();

            if (isNull)
            {
                Assert.That(image, Is.Null);
            }
            else
            {
                Assert.That(image, Is.Not.Null);
            }
        }
コード例 #18
0
        public ParametersNativeDll(IExternalType nativeDll, Interface inter, Uri dataFile, bool debuggerLaunch)
        {
            if (nativeDll == null)
                nativeDll = new ExternalType();

            _nativeDllImplementingNetAssembly = (ExternalType)nativeDll.Clone();
            _interface = inter;
            _debuggerLaunch = debuggerLaunch;
        }
コード例 #19
0
        public ComponentState()
        {
            ComponentType = new ExternalType();
            EngineType = new ExternalType();

            Arguments = new List<IArgument>();
            Inputs = new List<IBaseInput>();
            Outputs = new List<IBaseOutput>();
        }
コード例 #20
0
        public void CheckTypeReference(Node node)
        {
            ExternalType entity = node.Entity as ExternalType;

            if (entity != null)
            {
                this._assemblies.Add(entity.ActualType.Assembly);
            }
        }
コード例 #21
0
        public void FunctionType()
        {
            var externalType = new ExternalType(new FunctionType());

            Assert.Multiple(() =>
            {
                Assert.That(externalType.Type, Is.EqualTo(ExternalKind.Function));
                Assert.That(externalType.FunctionType, Is.EqualTo(new FunctionType()));
            });
        }
コード例 #22
0
        public void GlobalType()
        {
            var externalType = new ExternalType(new GlobalType(ValueType.I32, false));

            Assert.Multiple(() =>
            {
                Assert.That(externalType.Type, Is.EqualTo(ExternalKind.Global));
                Assert.That(externalType.GlobalType, Is.EqualTo(new GlobalType(ValueType.I32, false)));
            });
        }
コード例 #23
0
        public void TableType()
        {
            var externalType = new ExternalType(new TableType(0));

            Assert.Multiple(() =>
            {
                Assert.That(externalType.Type, Is.EqualTo(ExternalKind.Table));
                Assert.That(externalType.TableType, Is.EqualTo(new TableType(0)));
            });
        }
コード例 #24
0
        public void MemoryType()
        {
            var externalType = new ExternalType(new MemoryType(0));

            Assert.Multiple(() =>
            {
                Assert.That(externalType.Type, Is.EqualTo(ExternalKind.Memory));
                Assert.That(externalType.MemoryType, Is.EqualTo(new MemoryType(0)));
            });
        }
コード例 #25
0
        private void GenerateType(ExternalType type)
        {
            bool isEditorType    = IsEditorType(type);
            bool isFormatterType = IsFormatterType(type);

            if (!isEditorType && !isFormatterType)
            {
                return;
            }

            AppendUsings(new string[] {
                "Serenity",
                "Serenity.ComponentModel",
                "System",
                "System.Collections",
                "System.Collections.Generic",
                "System.ComponentModel"
            });

            sb.AppendLine();

            var    ns   = GetNamespace(type.Namespace);
            string name = type.Name + "Attribute";

            if (!string.IsNullOrEmpty(ns))
            {
                cw.Indented("namespace ");
                sb.AppendLine(ns);

                cw.InBrace(delegate
                {
                    if (isEditorType)
                    {
                        GenerateEditor(type, name);
                    }
                    else if (isFormatterType)
                    {
                        GenerateFormatter(type, name);
                    }
                });
            }
            else
            {
                if (isEditorType)
                {
                    GenerateEditor(type, name);
                }
                else if (isFormatterType)
                {
                    GenerateFormatter(type, name);
                }
            }

            AddFile(RemoveRootNamespace(ns, name) + ".cs");
        }
コード例 #26
0
 private static void Equals(ExternalType a, ExternalType b)
 {
     Assert.That(a.Equals(a), Is.True);
     Assert.That(a.Equals(b), Is.True);
     Assert.That(a.Equals(null), Is.False);
     Assert.That(a.Equals((object)a), Is.True);
     Assert.That(a.Equals((object)b), Is.True);
     Assert.That(a.Equals((object)null), Is.False);
     Assert.That(a.GetHashCode(), Is.EqualTo(b.GetHashCode()));
     Assert.That(a == b, Is.True);
     Assert.That(a != b, Is.False);
 }
コード例 #27
0
ファイル: ExpandMacros.cs プロジェクト: codehaus/boo
        private void ProcessMacro(IType macroType, MacroStatement node)
        {
            ExternalType type = macroType as ExternalType;

            if (null == type)
            {
                InternalClass klass = (InternalClass)macroType;
                ProcessInternalMacro(klass, node);
                return;
            }

            ProcessMacro(type.ActualType, node);
        }
コード例 #28
0
        private static void FixUpDomainTypes(MetaModel model)
        {
            // String
            ExternalType stringType = new ExternalType(model.Store);

            stringType.Name               = "String";
            stringType.Namespace          = "System";
            stringType.DisplayName        = "String";
            stringType.PropertyGridEditor = GetPropertyGridEditor(model, "StringEditorViewModel");
            model.DomainTypes.Add(stringType);

            // Boolean?
            ExternalType boolType = new ExternalType(model.Store);

            boolType.Name               = "Boolean?";
            boolType.Namespace          = "System";
            boolType.DisplayName        = "Boolean";
            boolType.PropertyGridEditor = GetPropertyGridEditor(model, "BooleanEditorViewModel");
            model.DomainTypes.Add(boolType);

            // Guid?
            ExternalType guidType = new ExternalType(model.Store);

            guidType.Name        = "Guid?";
            guidType.Namespace   = "System";
            guidType.DisplayName = "Guid";
            model.DomainTypes.Add(guidType);

            // Int32?
            ExternalType in32Type = new ExternalType(model.Store);

            in32Type.Name        = "Int32?";
            in32Type.Namespace   = "System";
            in32Type.DisplayName = "Integer";
            in32Type.RequiresSerializationConversion = true;
            in32Type.PropertyGridEditor = GetPropertyGridEditor(model, "IntegerEditorViewModel");
            model.DomainTypes.Add(in32Type);

            // Double?
            ExternalType dType = new ExternalType(model.Store);

            dType.Name        = "Double?";
            dType.Namespace   = "System";
            dType.DisplayName = "Double";
            dType.RequiresSerializationConversion = true;
            dType.PropertyGridEditor = GetPropertyGridEditor(model, "DoubleEditorViewModel");
            model.DomainTypes.Add(dType);
        }
コード例 #29
0
        private static bool IsFormatterType(ExternalType type)
        {
            if (type.IsAbstract == true)
            {
                return(false);
            }

            if (type.GenericParameters?.Count > 0)
            {
                return(false);
            }

            return(type.Interfaces != null && type.Interfaces.Any(x =>
                                                                  x == "Serenity.ISlickFormatter" ||
                                                                  x == "Slick.Formatter"));
        }
コード例 #30
0
        /// <summary>
        /// Only constructor
        /// </summary>
        /// <param name="identity">Derived class identity</param>
        /// <param name="derivedComponentType">Derived class Type</param>
        /// <param name="engineType">Runtime engine Type</param>
        /// <param name="useNativeDllArgument">Runtime engine requires location details of native engine DLL</param>
        public LinkableComponentV1Base(IIdentifiable identity, ExternalType derivedComponentType, ExternalType engineType, bool useNativeDllArgument)
            : base(identity, derivedComponentType, engineType, useNativeDllArgument)
        {
            // Null URI's cause problems so initialise to something wrong
            var uri = new Uri(@"http://sourceforge.net/projects/fluidearth/");
            var omiUri = new ArgumentUri(GetArgumentIdentity(Args.V1Omi), uri);

            // There is a design error should not have to add valueChanged in two ways here!

            omiUri.ValueChanged += new EventHandler<ArgumentBase.ValueChangedEventArgs>(omiUri_ValueChanged);

            Arguments.Add(omiUri);

            var argValue = Argument(GetArgumentIdentity(Args.V1Omi)).Value as ArgumentValueUri;

            argValue.ValueChanged += new EventHandler<ArgumentValueBase<Uri>.ValueChangedEventArgs>(OnArgOmiUriValueChanged);
        }
コード例 #31
0
        public override string GetMonikerQualifier(DomainXmlSerializerDirectory directory, ModelElement element)
        {
            if (directory == null)
            {
                throw new System.ArgumentNullException("directory");
            }
            if (element == null)
            {
                throw new System.ArgumentNullException("element");
            }

            ExternalType domainType = element as ExternalType;
            string       s          = domainType.MetaModel.Name;

            object[] objArr = new object[] { s };
            return(System.String.Format(CultureInfo.CurrentCulture, "/{0}", objArr));
        }
コード例 #32
0
        public void TestResolveExternalElements(ExternalType externalType, bool isEmpty)
        {
            SvgDocument.ResolveExternalElements = externalType;

            Assert.That(new SvgElementIdManager(null).ResolveExternalElements, Is.EqualTo(externalType));

            var svgFilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "a.svg");

            try
            {
                const string textId = "textId";

                var sb = new StringBuilder();
                sb.Append(@"<?xml version=""1.0"" encoding=""utf-8""?>");
                sb.Append(@"<svg xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink"" height=""25"" width=""65"">");
                sb.Append(@"  <defs>");
                sb.Append(@"    <text id=""ReferencedText"">Referenced</text>");
                sb.Append(@"  </defs>");
                sb.Append($@"  <text x=""0"" y=""10""><tref id=""{textId}"" xlink:href=""./{Path.GetFileName(svgFilePath)}#ReferencedText"" /></text>");
                sb.Append(@"</svg>");
                var svg = sb.ToString();

                File.AppendAllText(svgFilePath, svg);

                var svgDoc = SvgDocument.Open(svgFilePath);

                var svgTextRef   = svgDoc.GetElementById <SvgTextRef>(textId);
                var contentNodes = svgTextRef.GetContentNodes();

                if (isEmpty)
                {
                    Assert.That(contentNodes, Is.Empty);
                }
                else
                {
                    Assert.That(contentNodes, Is.Not.Empty);
                }
            }
            finally
            {
                File.Delete(svgFilePath);
            }
        }
コード例 #33
0
        /// <summary>
        /// Constructor for native coded IEngine
        /// </summary>
        /// <param name="identity">Identity for the component</param>
        /// <param name="derivedComponentType">Type of derived class encapsulated as an ExternalType</param>
        /// <param name="engineType">Type of IEngine derived class encapsulated as an ExternalType</param>
        /// <param name="useNativeDllArgument">True if engineType is actually a .NEt wrapper for
        /// a native implementation of IEngine, i.e. uses C interface to talk to engine which
        /// might be in some non .NET language e.g. C++/FORTRAN/Python etc</param>
        public BaseComponentTimeWithEngine(IIdentifiable identity, ExternalType derivedComponentType, ExternalType engineType, bool useNativeDllArgument)
            : base(identity, derivedComponentType, engineType, useNativeDllArgument)
        {
            _timeExtent = new TimeSet();
            _timeExtent.SetTimeHorizon(new Time());

            var argTime = new ArgumentTime(GetArgumentIdentity(ArgsWithEngineTime.TimeHorizon),
                new Time(_timeExtent.TimeHorizon));

            argTime.ValueChanged += new EventHandler<Argument<ArgumentValueTime>.ValueChangedEventArgs>(OnArgumentChangedTimeHorizon);

            Arguments.Add(argTime);

            // Base class sets typeof(RemotingServerEngineTime) not typeof(RemotingServerEngine)
            // Dont have a RemotingServerEngine as RemotingServerEngineTime only has one additional time method
            // which we can jsut ensure not to call!
            //((ArgumentParametersRemoting)Argument(GetArgumentIdentity(ArgsWithEngine.Remoting))).ParametersRemoting
            //    = new ParametersRemoting(typeof(RemotingServerEngineTime);
        }
コード例 #34
0
		private IMember FindByMetadataToken(IMember source, ExternalType targetType)
		{
			// HACK: since the API doesn't provide a way to correlate members on a generic type 
			// with the mapped members on a constructed type, we have to rely on them sharing the same
			// metadata token.

			MemberInfo sourceMemberInfo = ((IExternalEntity)source).MemberInfo;
			MemberFilter filter = delegate(MemberInfo candidate, object metadataToken)
			{
				return candidate.MetadataToken.Equals(metadataToken);
			};

			BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
			bindingFlags |= (source.IsStatic ? BindingFlags.Static : BindingFlags.Instance);

			MemberInfo[] mappedMemberInfos = targetType.ActualType.FindMembers(
				sourceMemberInfo.MemberType, bindingFlags, filter, sourceMemberInfo.MetadataToken);

			return (IMember)TypeSystemServices.Map(mappedMemberInfos[0]);
		}
コード例 #35
0
        private bool IsEditorType(ExternalType type)
        {
            if (type.IsAbstract)
                return false;

            if (type.GenericParameters.Count > 0)
                return false;

            if (!HasBaseType(type, "Serenity.Widget") &&
                !HasBaseType(type, "Serenity.Widget<any>"))
                return false;

            if (type.AssemblyName != null &&
                type.AssemblyName.StartsWith("Serenity."))
                return false;

            return GetAttribute(type, "Serenity.EditorAttribute", inherited: true) != null ||
                GetAttribute(type, "Serenity.ElementAttribute", inherited: true) != null ||
                GetAttribute(type, "Serenity.Decorators.registerEditor", inherited: true) != null ||
                GetAttribute(type, "Serenity.Decorators.editor", inherited: true) != null ||
                GetAttribute(type, "Serenity.Decorators.element", inherited: true) != null;
        }
コード例 #36
0
ファイル: FIM.MRE.cs プロジェクト: sorengranfeldt/mre
 void InvokeExternalMethod(string ExternalReferenceId, ExternalType Type, MVEntry mventry, CSEntry csentry)
 {
     if (!string.IsNullOrEmpty(ExternalReferenceId) && Externals.ContainsKey(ExternalReferenceId))
     {
         External external = Externals[ExternalReferenceId];
         if (external != null)
         {
             if (Type == ExternalType.Provision)
             {
                 external.Provision(mventry);
             }
             else if (Type == ExternalType.ShouldDeleteFromMV)
             {
                 external.ShouldDeleteFromMV(csentry, mventry);
             }
         }
         else
         {
             Tracer.TraceWarning("no-external-reference-found-for-referenceid {0}", ExternalReferenceId);
         }
     }
 }
コード例 #37
0
        private void GenerateFormatter(ExternalType type, string name)
        {
            cw.Indented("public partial class ");
            sb.Append(name);
            sb.AppendLine(" : CustomFormatterAttribute");

            cw.InBrace(delegate
            {
                cw.Indented("public const string Key = \"");
                sb.Append(type.FullName);
                sb.AppendLine("\";");
                sb.AppendLine();

                cw.Indented("public ");
                sb.Append(name);
                sb.AppendLine("()");
                cw.IndentedLine("    : base(Key)");
                cw.IndentedLine("{");
                cw.IndentedLine("}");

                GenerateOptionMembers(type, skip: null, isWidget: false);
            });
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public LinkableComponentV1FluidEarth()
            : base(new Identity(new Describes("FluidEarthV1", "Converts a OpenMI V1 component implemented using FluidEarth V1 to OpenMI V2")),
                new ExternalType(typeof(LinkableComponentV1FluidEarth)),
                new ExternalType(typeof(IProxyEngine5)),
                true)
        {
            var v1ServerType = new ArgumentExternalType(GetArgumentIdentity(ArgsFE.ExternalTypeV1EngineServer), new ExternalType());

            Arguments.Add(v1ServerType);

            // UnitTests use shadow copying, so have to go this route
            var uriExecuting = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            var fileExecuting = new FileInfo(uriExecuting.LocalPath);

            var enginePath = Path.Combine(fileExecuting.DirectoryName, "FluidEarth2_Sdk_V1Wrappers.dll");

            var engineType = new ExternalType();
            engineType.Initialise(enginePath, "FluidEarth2.Sdk.V1Wrappers.Engine5");

            ArgumentParametersNativeDll = new ParametersNativeDll(engineType,
                ParametersNativeDll.Interface.FluidEarth2_Sdk_Interfaces_IEngineTime,
                null, false);
        }
コード例 #39
0
        public override string CalculateQualifiedName(DomainXmlSerializerDirectory directory, ModelElement element)
        {
            if (directory == null)
            {
                throw new System.ArgumentNullException("directory");
            }
            if (element == null)
            {
                throw new System.ArgumentNullException("element");
            }

            ExternalType domainType = element as ExternalType;
            string       s1         = this.GetMonikerQualifier(directory, domainType);
            string       s2         = domainType.Namespace;
            string       s3         = domainType.Name;

            object[] objArr = new object[] {
                s1,
                s2,
                s3
            };
            return(System.String.Format(CultureInfo.CurrentCulture, "{0}/{1}/{2}", objArr));
        }
コード例 #40
0
        public BaseComponentWithEngine(IIdentifiable identity, ExternalType derivedComponentType, ExternalType engineType, bool useNativeDllArgument)
            : base(identity, true, null, null, null, null)
        {
            _derivedComponentType = derivedComponentType;
            _engineType = engineType;

            _useNativeDll = useNativeDllArgument;

            SetArgCaption();

            ArgumentsAddRange(new IArgument[]
            {
                _argCaption,
                new ArgumentParametersDiagnosticsEngine(GetArgumentIdentity(ArgsWithEngine.Diagnostics),
                    new ParametersDiagnosticsNative()),
                new ArgumentParametersRemoting(GetArgumentIdentity(ArgsWithEngine.Remoting),
                    new ParametersRemoting()),
            });

            if (_useNativeDll)
                Arguments.Add(new ArgumentNativeDll(GetArgumentIdentity(ArgsWithEngine.NativeDll),
                    new ParametersNativeDll()));
        }
コード例 #41
0
        private IProperty GetProperty(IType type, string name)
        {
            ExternalType external = type as ExternalType;

#if NET_2_0
            MixedGenericType mixed = type as MixedGenericType;

            if (mixed != null)
            {
                IProperty definition = GetProperty(mixed.GenericDefinition, name);
                return((IProperty)mixed.MapMember(definition));
            }
#endif

            if (external != null)
            {
                return((IProperty)TypeSystemServices.Map(external.ActualType.GetProperty(name)));
            }

            else
            {
                throw new ArgumentException(string.Format("Invalid type for GetMethod: {0}", type));
            }
        }
コード例 #42
0
            public static LinkableComponentOpenMIV1Wrapper ImportComponent(Component1Type v1Type, XElement xLinkableComponentV1, IDocumentAccessor accessor)
            {
                var assembly = Utilities.Xml.GetAttribute(xLinkableComponentV1, "Assembly");
                var type = Utilities.Xml.GetAttribute(xLinkableComponentV1, "Type");
                var assemblyUri = new Uri(accessor.Uri, assembly);

                string path;

                if (!FluidEarth2.Sdk.Utilities.UriIsFilePath(assemblyUri, out path) || !File.Exists(path))
                    throw new Exception("OMI file Assembly attribute cannot be resolved to an existing file, correct OMI file and retry. Used: "
                        + assembly);

                var componentTypeV1 = new ExternalType(accessor);
                componentTypeV1.Initialise(assemblyUri.LocalPath, type);

                Type tComponentV1;
                var component1 = componentTypeV1.CreateInstance(out tComponentV1) as ILinkableComponent1;

                if (component1 == null)
                    throw new Exception("Cannot instantiate " + componentTypeV1.ToString());

                var ns1 = Omi.Component.NamespaceOpenMIv1;

                var xArguments = xLinkableComponentV1
                    .Element(ns1.GetName("Arguments"));

                var args1 = Arguments1(xArguments, ns1, accessor.Uri);

                component1.Initialize(args1.ToArray());

                switch (v1Type)
                {
                    case Component1Type.OpenMIGeneric:
                        return new LinkableComponentOpenMIV1Wrapper(component1, componentTypeV1.DocumentAccessor, args1.ToList());
                    case Component1Type.FluidEarthEngine5:
                        return new LinkableComponentFluidEarthV1Wrapper(component1, componentTypeV1.DocumentAccessor, args1.ToList());
                    default:
                        throw new NotImplementedException(v1Type.ToString());
                }
            }
コード例 #43
0
		public ExternalGenericMapping(ExternalType constructedType, IType[] arguments) : base(constructedType, arguments)
		{
			_constructedType = constructedType;
		}
コード例 #44
0
        public void Initialise(string initialisingXml, IDocumentAccessor accessor)
        {
            try
            {
                _initialisingXml = XElement.Parse(initialisingXml);

                var arguments = Persistence.Arguments
                    .Parse(_initialisingXml, accessor);

                var remotingId = BaseComponentWithEngine.GetArgumentIdentity(
                    BaseComponentWithEngine.ArgsWithEngine.Remoting).Id;
                var diagnosticsId = BaseComponentWithEngine.GetArgumentIdentity(
                    BaseComponentWithEngine.ArgsWithEngine.Diagnostics).Id;

                var remoting = arguments
                    .Where(a => a.Id == remotingId)
                    .Single();

                var diagnostics = arguments
                    .Where(a => a.Id == diagnosticsId)
                    .Single();

                _remotingData = new ParametersRemoting();
                _remotingData.ValueAsString = remoting.ValueAsString;

                _diagnostics = new ParametersDiagnosticsNative();
                _diagnostics.ValueAsString = diagnostics.ValueAsString;

                if (_remotingData.Protocol == RemotingProtocol.ipcAuto)
                {
                    string args = string.Format(
                        "ipcAuto {0} {1}", _remotingData.ObjectUri, _remotingData.PortName);

                    if (_remotingData.ServerLaunchDebugger)
                        args += " launchDebugger";
                    if (_remotingData.EnsureSecurity)
                        args += " ensureSecurity";
                    if (_remotingData.ServerTraceEngine)
                        args += " traceEngine";

                    var serverType = new ExternalType(typeof(RemotingServerEngineTime));

                    WriteLine("IPC Auto Process");
                    WriteLine("\tServer: " + serverType.Url.LocalPath, false);
                    WriteLine("\tArgs: " + args, false);
                    WriteLine("\tRedirect Standard Output (if true could be VERY slow): "
                        + _remotingData.IpcAutoRedirectStdOut.ToString(), false);

                    _process = new RemotingProcess("RemotingServerEngineTime");
                    _process.Start(serverType.Url.LocalPath, args, _remotingData.IpcAutoRedirectStdOut);

                    WriteLine("Process started");
                }

                WriteLine(_remotingData.Details());

                switch (_remotingData.Protocol)
                {
                    case RemotingProtocol.ipc:
                    case RemotingProtocol.ipcAuto:
                        WriteLine("IPC Connection");
                        _connection = new RemotingConnectionIpc();
                        break;
                    case RemotingProtocol.tcp:
                        WriteLine("TCP Connection");
                        _connection = new RemotingConnectionTcp();
                        break;
                    case RemotingProtocol.http:
                        WriteLine("HTTP Connection");
                        _connection = new RemotingConnectionHttp();
                        break;
                    case RemotingProtocol.inProcess:
                    default:
                        throw new NotImplementedException(_remotingData.Protocol.ToString());
                }

                WriteLine("\tClient Uri: " + _remotingData.ClientUri, false);
                WriteLine("\tEnsure Security: " + _remotingData.EnsureSecurity, false);
                WriteLine("\tConnection TimeOut: " + _remotingData.ConnectionTimeOut, false);

                _connection.Start(_remotingData.ClientUri, _remotingData.EnsureSecurity, _remotingData.ConnectionTimeOut, typeof(IEngine));

                WriteLine("\tConnection started.", false);
                WriteLine(string.Format("... pause {0} seconds before pinging engine ...", _remotingData.ConnectionSleep / 1000.0));

                Thread.Sleep(_remotingData.ConnectionSleep);

                string ping = EngineProxy.Ping();

                WriteLine("Engine Ping: " + ping);

                WriteLine("Engine Initialising ...");
                EngineProxy.Initialise(_initialisingXml.ToString());
                WriteLine("\tInitialised.", false);
            }
            catch (System.Exception e)
            {
                throw EngineMethodCatch("Initialise", e);
            }
        }
コード例 #45
0
        public virtual void AddDetailsAsWikiText(StringBuilder sb)
        {
            sb.AppendLine("= Identifiable Type");
            sb.AppendLine(string.Format("* Unique Id: \"{0}\"", _guid));
            sb.AppendLine(string.Format("* Interface: \"{0}\"", _interface));
            sb.AppendLine("== Identity ");
            sb.AppendLine(string.Format("* Caption: \"{0}\"", _cachedInstanceDescribes.Caption));
            sb.AppendLine(string.Format("* Id: \"{0}\"", _cachedInstanceId));
            sb.AppendLine(string.Format("=== Description"));

            if (Sdk.Utilities.IsProbablyWikiText(_cachedInstanceDescribes.Description))
                sb.AppendLine(_cachedInstanceDescribes.Description);
            else
            {
                sb.AppendLine("{{{");
                sb.AppendLine(_cachedInstanceDescribes.Description);
                sb.AppendLine("}}}");
            }

            sb.AppendLine("== Instance");

            if (_itemInstance != null)
            {
                var externalType = new ExternalType(_itemInstance.GetType());

                sb.AppendLine(string.Format("* Type: \"{0}\"", externalType.TypeName));
                sb.AppendLine(string.Format("* Assembly: \"{0}\"", externalType.AssemblyName));
                sb.AppendLine(string.Format("* Url: \"{0}\"", externalType.Url.AbsoluteUri));
            }

            if (_xConstructor != null)
            {
                sb.AppendLine("=== XML Persistence");
                sb.AppendLine("{{{");
                sb.AppendLine(_xConstructor.ToString());
                sb.AppendLine("}}}");
            }
        }
コード例 #46
0
        private static void FixUpDomainTypes(MetaModel model)
        {
            // String
            ExternalType stringType = new ExternalType(model.Store);
            stringType.Name = "String";
            stringType.Namespace = "System";
            stringType.DisplayName = "String";
            stringType.PropertyGridEditor = GetPropertyGridEditor(model, "StringEditorViewModel");
            model.DomainTypes.Add(stringType);

            // Boolean?
            ExternalType boolType = new ExternalType(model.Store);
            boolType.Name = "Boolean?";
            boolType.Namespace = "System";
            boolType.DisplayName = "Boolean";
            boolType.PropertyGridEditor = GetPropertyGridEditor(model, "BooleanEditorViewModel");
            model.DomainTypes.Add(boolType);

            // Guid?
            ExternalType guidType = new ExternalType(model.Store);
            guidType.Name = "Guid?";
            guidType.Namespace = "System";
            guidType.DisplayName = "Guid";
            model.DomainTypes.Add(guidType);

            // Int32?
            ExternalType in32Type = new ExternalType(model.Store);
            in32Type.Name = "Int32?";
            in32Type.Namespace = "System";
            in32Type.DisplayName = "Integer";
            in32Type.RequiresSerializationConversion = true;
            in32Type.PropertyGridEditor = GetPropertyGridEditor(model, "IntegerEditorViewModel");
            model.DomainTypes.Add(in32Type);

            // Double?
            ExternalType dType = new ExternalType(model.Store);
            dType.Name = "Double?";
            dType.Namespace = "System";
            dType.DisplayName = "Double";
            dType.RequiresSerializationConversion = true;
            dType.PropertyGridEditor = GetPropertyGridEditor(model, "DoubleEditorViewModel");
            model.DomainTypes.Add(dType);
        }
コード例 #47
0
		public ExternalConstructedTypeInfo(IReflectionTypeSystemProvider tss, ExternalType type)
		{
			_type = type;
			_tss = tss;
		}
コード例 #48
0
 public BaseComponentWithEngine(IIdentifiable identity, ExternalType derivedComponentType, ExternalType engineType)
     : this(identity, derivedComponentType, engineType, false)
 {
 }
        public void SetDefaultArguments()
        {
            // UnitTests use shadow copying, so have to go this route
            var uriExecuting = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            var fileExecuting = new FileInfo(uriExecuting.LocalPath);

            var enginePath = Path.Combine(fileExecuting.DirectoryName, "FluidEarth2_Sdk_V1Wrappers.dll");

            var engineType = new ExternalType();
            engineType.Initialise(enginePath, "FluidEarth2.Sdk.V1Wrappers.Engine5");

            ArgumentParametersNativeDll = new ParametersNativeDll(engineType,
                ParametersNativeDll.Interface.FluidEarth2_Sdk_Interfaces_IEngineTime,
                null, false);

            var serverExe = Arguments
                .Where(a => a.Caption == "FluidEarth_SDK.ArgFile.ServerExe"
                    | a.Caption == "OpenWEB_SDK.ArgFile.ServerExe")
                .SingleOrDefault();

            if (serverExe != null)
            {
                var serverType = Arguments
                    .Where(a => a.Caption == "FluidEarth_SDK.Arg.ServerType"
                        || a.Caption == "OpenWEB_SDK.Arg.ServerType")
                    .SingleOrDefault();

                string typeName = string.Empty;

                // Guess that implemented followed recommended naming conventions and structure so Engine exists

                if (serverType != null)
                    typeName = serverType
                        .ValueAsString
                        .Substring(0, serverType.ValueAsString.LastIndexOf(".")) + ".Engine";

                var nativeEngineWrapperType = new ExternalType();
                nativeEngineWrapperType.Initialise(
                    serverExe.ValueAsString,
                    typeName);

                try
                {
                    Type type;
                    if (nativeEngineWrapperType.CreateInstance(out type) == null)
                        nativeEngineWrapperType.TypeName = string.Empty;
                }
                catch (Exception)
                {
                    nativeEngineWrapperType.TypeName = string.Empty;
                }

                if (nativeEngineWrapperType.TypeName == string.Empty)
                {
                    // try again with unmodified name
                    typeName = serverType.ValueAsString;
                    nativeEngineWrapperType.Initialise(serverExe.ValueAsString, typeName);

                    try
                    {
                        Type type;
                        if (nativeEngineWrapperType.CreateInstance(out type) == null)
                            nativeEngineWrapperType.TypeName = string.Empty;
                    }
                    catch (Exception)
                    {
                        nativeEngineWrapperType.TypeName = string.Empty;
                    }
                }

                ArgumentEngineExternalType = nativeEngineWrapperType;
            }
        }
コード例 #50
0
            public static bool Parse( 
                XElement xLinkableComponent,
                IDocumentAccessor accessor,
                List<IReport> reports,
                out ExternalType component,
                out SupportedPlatforms platforms,
                out List<Argument> argumentsOmi)
            {
                Contract.Requires(reports != null, "reports != null");

                component = null;
                platforms = SupportedPlatforms.Unknown;
                argumentsOmi = new List<Argument>();

                var ns = xLinkableComponent.Name.Namespace;

                if (!Validates(xLinkableComponent, Xsd.ComponentV2, reports))
                    return false;

                var xArgs = xLinkableComponent.Elements(NamespaceOpenMIv2.GetName(XArguments)).SingleOrDefault();
                var xArguments = xArgs != null
                    ? xArgs.Elements(NamespaceOpenMIv2.GetName(XArgument))
                    : null;

                var xPlatforms = xLinkableComponent.Elements(NamespaceOpenMIv2.GetName(XPlatforms)).SingleOrDefault();

                var assembly = Utilities.Xml.GetAttribute(xLinkableComponent, XAssembly);
                var type = Utilities.Xml.GetAttribute(xLinkableComponent, XType);

                AssemblyName assemblyName;
                Uri codeBaseUri = null;

                if (!ExternalType.AssemblyNameGet(assembly, codeBaseUri, type, reports, accessor, out assemblyName))
                    return false;

                component = new ExternalType(accessor);
                component.Initialise(assemblyName, type);

                if (xArguments != null)
                    argumentsOmi.AddRange(xArguments
                        .Select(x => new Argument(x, accessor)));

                platforms = Platforms.Parse(xPlatforms, accessor);

                return true;
            }
コード例 #51
0
            public static bool Instantiate(
                ExternalType componentType,
                SupportedPlatforms platforms,
                List<IReport> reports,
                out IBaseLinkableComponent component)
            {
                Contract.Requires(componentType != null, "componentType != null");
                Contract.Requires(reports != null, "reports != null");

                component = null;

                Type type;

                try
                {
                    component = componentType
                        .CreateInstance(out type) as IBaseLinkableComponent;
                }
                catch (System.Exception e)
                {
                    reports.Add(Report.Error(Report.ResourceIds.Instantiation,
                        "Cannot instantiate IBaseLinkableComponent", e.Message));
                    return false;
                }

                if (component == null)
                {
                    reports.Add(Report.Error(Report.ResourceIds.Instantiation,
                        "Cannot instantiate IBaseLinkableComponent", type.ToString()));
                    return false;
                }

                return true;
            }
コード例 #52
0
 public LinkableComponentTimeWithEngine(IIdentifiable identity, ExternalType derivedComponentType, ExternalType engineType, bool useNativeDllArgument)
     : base(identity, derivedComponentType, engineType, useNativeDllArgument)
 {
 }
コード例 #53
0
        /// <summary>
        /// Initialisation specific to Pond
        /// </summary>
        /// <param name="reinitialising">True if previously been through here before</param>
        protected override void DoInitialise(bool reinitialising)
        {
            ComponentState state = null;

            if (!reinitialising)
            {
                var stateUri = ArgumentStateUri;

                if (stateUri != null && stateUri.IsFile && File.Exists(stateUri.LocalPath))
                {
                    var accessor = new DocumentExistingFile(stateUri);

                    var document = XDocument.Load(stateUri.LocalPath);

                    state = new ComponentState();

                    state.Initialise(document.Root, accessor);

                    SetIdentity(state);

                    Caption = state.Caption; // as modified via argument

                    EngineType = new ExternalType(state.EngineType);

                    UseNativeDll = state.UseNativeEngine;
                }
            }

            base.DoInitialise(reinitialising);

            if (reinitialising || state == null)
                return;

            foreach (var arg in state.Arguments)
                Arguments.Add(arg);

            foreach (var input in state.Inputs)
                Add(input as BaseInput);

            foreach (var putput in state.Outputs)
                Add(putput as BaseOutput);
        }
        protected virtual ArgumentUri InitialiseArguments(ILinkableComponentVersion1 component1, List<Utilities.Standard1.Argument1> args1)
        {
            if (component1 == null)
            {
                var uri = new Uri(@"http://sourceforge.net/projects/fluidearth/");
                var persistence = new ArgumentUri(GetArgumentIdentity(ArgsV1Wrapper.Persistence), uri);

                // For Uri's have to use a valid Url to initialise, then change to relevant value
                Arguments.Add(persistence);
                Arguments.Add(new ArgumentExternalType(GetArgumentIdentity(ArgsV1Wrapper.EngineExternalType),
                    new ExternalType(DocumentAccessor)));

                if (_includeUpdateTimeInterval)
                    Arguments.Add(new ArgumentTimeInterval(GetArgumentIdentity(ArgsV1Wrapper.UpdateTimeInterval),
                        new TimeInterval()));

                if (args1 != null)
                    foreach (var a1 in args1)
                        Arguments.Add(new ArgumentStandard1(a1));

                return persistence;
            }

            ArgumentTimeHorizon = new Time(
                component1.TimeHorizon.Start.ModifiedJulianDay,
                component1.TimeHorizon.End.ModifiedJulianDay);

            ExternalType component1Type = new ExternalType(DocumentAccessor);
            component1Type.Initialise(component1.GetType());

            var uriP = new Uri(
                DocumentAccessor.Uri
                    .LocalPath
                    .Substring(0, DocumentAccessor.Uri.LocalPath.LastIndexOf('.')) + Caption + "Persist.xml");

            var uriPersistence = new ArgumentUri(GetArgumentIdentity(ArgsV1Wrapper.Persistence), uriP);

            uriPersistence.ValueAsString =
                new Uri(
                    DocumentAccessor.Uri
                        .LocalPath
                        .Substring(0, DocumentAccessor.Uri.LocalPath.LastIndexOf('.')) + Caption + "Persist.xml")
                .AbsoluteUri;

            Arguments.Add(uriPersistence);
            Arguments.Add(new ArgumentExternalType(GetArgumentIdentity(ArgsV1Wrapper.EngineExternalType),
                component1Type));

            if (_includeUpdateTimeInterval)
                Arguments.Add(new ArgumentTimeInterval(GetArgumentIdentity(ArgsV1Wrapper.UpdateTimeInterval),
                    new TimeInterval()));

            foreach (var a1 in args1)
                Arguments.Add(new ArgumentStandard1(a1));

            return uriPersistence;
        }
 protected LinkableComponentOpenMIV1Wrapper(IIdentifiable identity, ExternalType derivedComponentType, ExternalType engineType, bool useNativeDllArgument)
     : base(identity, derivedComponentType, engineType, useNativeDllArgument)
 {
 }
コード例 #56
0
            public static LinkableComponentOpenMIV1Wrapper CreateWrappedComponent(ExternalType component, IEnumerable<Argument1> arguments)
            {
                Type tComponentV1;
                ILinkableComponent1 component1
                    = component.CreateInstance(out tComponentV1)
                    as ILinkableComponent1;

                if (component1 == null)
                    throw new Exception("Cannot instantiate " + component.ToString());

                component1.Initialize(arguments.ToArray());

                bool isFluidEarthV1 = tComponentV1.BaseType != null &&
                    tComponentV1.BaseType.AssemblyQualifiedName.Contains("FluidEarth.Sdk.LinkableComponent");

                return isFluidEarthV1
                    ? new LinkableComponentFluidEarthV1Wrapper(component1, component.DocumentAccessor, arguments.ToList())
                    : new LinkableComponentOpenMIV1Wrapper(component1, component.DocumentAccessor, arguments.ToList());
            }
コード例 #57
0
 public ComponentTimeWithEngine(ExternalType engineType)
     : base(new Identity("FluidEarth2.Sdk.ComponentTimeWithEngine", "ComponentTimeWithEngine"),
         new ExternalType(typeof(ComponentTimeWithEngine)), engineType)
 {
 }
        /// <summary>
        /// Intercept base initialise call to update references to IEngine server and native DLL.
        /// </summary>
        /// <param name="reinitialising">True if component has been initialised before</param>
        protected override void DoInitialise(bool reinitialising)
        {
            base.DoInitialise(reinitialising);

            var serverExe = Arguments
                .Where(a => a.Caption == "FluidEarth_SDK.ArgFile.ServerExe"
                    | a.Caption == "OpenWEB_SDK.ArgFile.ServerExe")
                .SingleOrDefault();

            if (serverExe != null)
            {
                var serverType = Arguments
                    .Where(a => a.Caption == "FluidEarth_SDK.Arg.ServerType"
                        || a.Caption == "OpenWEB_SDK.Arg.ServerType")
                    .SingleOrDefault();

                string typeName = string.Empty;

                // Guess that implemented followed recommended naming conventions and structure so Engine exists

                if (serverType != null)
                    typeName = serverType
                        .ValueAsString
                        .Substring(0, serverType.ValueAsString.LastIndexOf(".")) + ".Engine";

                var nativeEngineWrapperType = new ExternalType();
                nativeEngineWrapperType.Initialise(
                    serverExe.ValueAsString,
                    typeName);

                try
                {
                    Type type;
                    if (nativeEngineWrapperType.CreateInstance(out type) == null)
                        nativeEngineWrapperType.TypeName = string.Empty;
                }
                catch (Exception)
                {
                    nativeEngineWrapperType.TypeName = string.Empty;
                }

                if (nativeEngineWrapperType.TypeName == string.Empty)
                {
                    // try again with unmodified name
                    typeName = serverType.ValueAsString;
                    nativeEngineWrapperType.Initialise(serverExe.ValueAsString, typeName);

                    try
                    {
                        Type type;
                        if (nativeEngineWrapperType.CreateInstance(out type) == null)
                            nativeEngineWrapperType.TypeName = string.Empty;
                    }
                    catch (Exception)
                    {
                        nativeEngineWrapperType.TypeName = string.Empty;
                    }
                }

                ArgumentExternalTypeV1EngineServer = nativeEngineWrapperType;
            }
        }
コード例 #59
0
 public ExternalItem()
 {
     FID = -1;
     FType = ExternalType.Base;
     FKey = "";
     FValue = "";
     FImage = 0;
 }
コード例 #60
0
        public IBaseLinkableComponent Instantiate()
        {
            var identity = new Identity(string.Empty);
            var instantiationType = new ExternalType(typeof(ComponentStateTimeWithEngine));

            var component = new ComponentStateTimeWithEngine();

            foreach (var arg in Arguments)
                component.Arguments.Add(arg);

            component.Initialize();

            return component;
        }