Beispiel #1
0
        void DoCopy(InstallSource source, InstallDestination destination)
        {
            source.InstallEnvironment      = environment;
            destination.InstallEnvironment = environment;

            /* -- no, we don't do that anymore
             * if (destination.Exists)
             * {
             *  destination.Delete();
             * }
             */

            foreach (Type t in source.Types)
            {
                // Console.Out.WriteLine("{0}[{1}] -> {1}", source, t.Name, destination);
                TypedStream <object> dstStream = destination.OpenForWriting(t);
                using (TypedStream <object> srcStream = source.OpenForReading(t))
                {
                    dstStream.Array = srcStream.Array;
                    dstStream.Dispose();
                }
            }
        }
Beispiel #2
0
        public static int ReadObject(ExecutionContext context, object[] values, out object[] inlineParameters)
        {
            inlineParameters = EmptyParameters;

            if (values.Length < 1 || values.Length > 4)
            {
                context.Error.WriteLine("Invalid syntax: ReadObject NodePath [TypedStream [Index]]");
                return(-1);
            }

            string path  = values[0].ToString();
            Type   type  = null;
            uint   index = 0;

            // We first get type.
            if (values.Length > 1)
            {
                type = Type.GetType(values[1].ToString());
                if (type == null)
                {
                    context.Error.WriteLine("Type '{0}' not resolved.", values[1].ToString());
                    return(-1);
                }
            }

            if (values.Length > 2)
            {
                if (values[2] is uint)
                {
                    index = (uint)values[2];
                }
                else if (values[3] is int)
                {
                    index = (uint)((int)values[2]);
                }
                else if (!uint.TryParse(values[2].ToString(), out index))
                {
                    context.Error.WriteLine("The index is not a number: {0}", values[2].ToString());
                    return(-1);
                }
            }


            Node <object> node = context.ShellApp.WorkingDirectory.Find(path);

            if (node == null)
            {
                context.Error.WriteLine("Path '{0}' does not exist", path);
                return(-1);
            }

            TypedStream <object> typedStream = null;

            try
            {
                if (type == null)
                {
                    typedStream = node.OpenForReading();
                }
                else
                {
                    typedStream = node.Open(type, OpenMode.Read);
                }

                if (typedStream == null)
                {
                    context.Error.WriteLine("Typed stream '{0}' does not exist on path '{1}'", type, path);
                    return(-1);
                }

                // We write it.
                inlineParameters = new object[] { typedStream.Read(index) };
            }
            finally
            {
                if (typedStream != null)
                {
                    typedStream.Dispose();
                }
            }
            return(1);
        }