Example #1
0
 /// <summary>
 /// Saves configuration to source
 /// </summary>
 public virtual void Save()
 {
     if (m_Root != null)
     {
         m_Root.ResetModified();
     }
 }
Example #2
0
            /// <summary>Provides package descriptor</summary>
            /// <param name="name">Mnemonic name of the package (i.e. application name)</param>
            /// <param name="source">Source directory where to take files from</param>
            /// <param name="relPath">Relative path which is appended to the root path where files will be placed</param>
            public PackageInfo(string name, FileSystemDirectory source, string relPath)
            {
                Name         = name ?? CoreConsts.UNKNOWN;
                Source       = source;
                RelativePath = relPath;

                ConfigSectionNode manifest = null;
                var mFile = source.GetFile(ManifestUtils.MANIFEST_FILE_NAME);

                if (mFile != null)
                {
                    try
                    {
                        manifest = LaconicConfiguration.CreateFromString(mFile.ReadAllText()).Root;
                    }
                    catch (Exception error)
                    {
                        throw new AzosIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_MANIFEST_READ_ERROR.Args(Name, error.ToMessageWithType()), error);
                    }
                }

                if (manifest == null)
                {
                    throw new AzosIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_WITHOUT_MANIFEST_ERROR.Args(Name, ManifestUtils.MANIFEST_FILE_NAME));
                }

                manifest.AttrByName(ManifestUtils.CONFIG_NAME_ATTR, true).Value       = name;
                manifest.AttrByName(ManifestUtils.CONFIG_LOCAL_PATH_ATTR, true).Value = relPath;
                manifest.ResetModified();

                Manifest = manifest;
            }
        // -arg1 -arg2 -arg3 opt1 opt2 -arg4 optA=v1 optB=v2
        private void parseArgs()
        {
            m_Root = new ConfigSectionNode(this, null, ROOT_NODE_NAME, string.Empty);

            var uargcnt = 1; //unknown arg length

            for (int i = 0; i < m_Args.Length;)
            {
                var argument = m_Args[i];

                if (argument.Length > 1 && ((!m_InhibitSlashArg && argument.StartsWith(ARG_PREFIX_SLASH)) || argument.StartsWith(ARG_PREFIX_DASH)))
                {
                    argument = argument.Remove(0, 1);//get rid of prefix
                    var argNode = m_Root.AddChildNode(argument, null);

                    var uopcnt = 1;               //unknown option length
                    for (i++; i < m_Args.Length;) //read args's options
                    {
                        var option = m_Args[i];
                        if ((!m_InhibitSlashArg && option.StartsWith(ARG_PREFIX_SLASH)) || option.StartsWith(ARG_PREFIX_DASH))
                        {
                            break;
                        }
                        i++;

                        var j = option.IndexOf(OPTION_EQ);

                        if (j < 0)
                        {
                            argNode.AddAttributeNode(string.Format("?{0}", uopcnt), option);
                            uopcnt++;
                        }
                        else
                        {
                            var name = option.Substring(0, j);
                            var val  = (j < option.Length - 1) ? option.Substring(j + 1) : string.Empty;

                            if (string.IsNullOrEmpty(name))
                            {
                                name = string.Format("?{0}", uopcnt);
                                uopcnt++;
                            }
                            argNode.AddAttributeNode(name, val);
                        }
                    }
                }
                else
                {
                    m_Root.AddAttributeNode(string.Format("?{0}", uargcnt), argument);
                    uargcnt++;
                    i++;
                }
            }

            m_Root.ResetModified();
        }
        // -arg1 -arg2 -arg3 opt1 opt2 -arg4 optA=v1 optB=v2
        private void parseArgs()
        {
            m_Root = new ConfigSectionNode(this, null, ROOT_NODE_NAME, string.Empty);

              var uargcnt = 1; //unknown arg length
              for (int i = 0; i < m_Args.Length; )
              {
            var argument = m_Args[i];

            if (argument.Length > 1 && (argument.StartsWith(ARG_PREFIX1) || argument.StartsWith(ARG_PREFIX2)))
            {
              argument = argument.Remove(0, 1);//get rid of prefix
              var argNode = m_Root.AddChildNode(argument, null);

              var uopcnt = 1;//unknown option length
              for (i++; i < m_Args.Length; )//read args's options
              {
            var option = m_Args[i];
            if (option.StartsWith(ARG_PREFIX1) || option.StartsWith(ARG_PREFIX2)) break;
            i++;

            var j = option.IndexOf(OPTION_EQ);

            if (j < 0)
            {
              argNode.AddAttributeNode(string.Format("?{0}", uopcnt), option);
              uopcnt++;
            }
            else
            {
              var name = option.Substring(0, j);
              var val = (j < option.Length - 1) ? option.Substring(j + 1) : string.Empty;

              if (string.IsNullOrEmpty(name))
              {
                name = string.Format("?{0}", uopcnt);
                uopcnt++;
              }
              argNode.AddAttributeNode(name, val);
            }
              }
            }
            else
            {
              m_Root.AddAttributeNode(string.Format("?{0}", uargcnt), argument);
              uargcnt++;
              i++;
            }
              }

              m_Root.ResetModified();
        }