本文整理汇总了C#中KeePass.Plugins.PlgxPluginInfo类的典型用法代码示例。如果您正苦于以下问题:C# PlgxPluginInfo类的具体用法?C# PlgxPluginInfo怎么用?C# PlgxPluginInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlgxPluginInfo类属于KeePass.Plugins命名空间,在下文中一共展示了PlgxPluginInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddCacheAssembly
public static string AddCacheAssembly(string strAssemblyPath, PlgxPluginInfo plgx)
{
if(string.IsNullOrEmpty(strAssemblyPath)) { Debug.Assert(false); return null; }
string strNewFile = GetCacheFile(plgx, false, true);
File.Copy(strAssemblyPath, strNewFile, true);
return strNewFile;
}
开发者ID:rassilon,项目名称:keepass,代码行数:9,代码来源:PlgxCache.cs
示例2: AddCacheFile
public static string AddCacheFile(string strNormalFile, PlgxPluginInfo plgx)
{
if(string.IsNullOrEmpty(strNormalFile)) { Debug.Assert(false); return null; }
string strNewFile = UrlUtil.EnsureTerminatingSeparator(GetCacheDirectory(
plgx, true), false) + UrlUtil.GetFileName(strNormalFile);
File.Copy(strNormalFile, strNewFile, true);
return strNewFile;
}
开发者ID:rassilon,项目名称:keepass,代码行数:10,代码来源:PlgxCache.cs
示例3: Load
private static void Load(string strFilePath, PlgxPluginInfo plgxOutInfo)
{
if(strFilePath == null) throw new ArgumentNullException("strFilePath");
plgxOutInfo.CsprojFilePath = strFilePath;
XmlDocument doc = new XmlDocument();
doc.Load(strFilePath);
ReadProject(doc.DocumentElement, plgxOutInfo);
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:11,代码来源:PlgxCsprojLoader.cs
示例4: LoadDefault
public static void LoadDefault(string strDirPath, PlgxPluginInfo plgxOutInfo)
{
if(plgxOutInfo == null) throw new ArgumentNullException("plgxOutInfo");
string[] vCsproj = UrlUtil.GetFilePaths(strDirPath, "*.csproj",
SearchOption.AllDirectories).ToArray();
if(vCsproj.Length == 1)
{
plgxOutInfo.ProjectType = PlgxProjectType.CSharp;
PlgxCsprojLoader.Load(vCsproj[0], plgxOutInfo);
return;
}
// string[] vVbproj = UrlUtil.GetFilePaths(strDirPath, "*.vbproj",
// SearchOption.AllDirectories).ToArray();
// if(vVbproj.Length == 1)
// {
// plgxOutInfo.ProjectType = PlgxProjectType.VisualBasic;
// PlgxCsprojLoader.Load(vVbproj[0], plgxOutInfo);
// return;
// }
throw new InvalidOperationException(KPRes.CsprojCountError);
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:24,代码来源:PlgxCsprojLoader.cs
示例5: Compile
private static string Compile(string strTmpRoot, PlgxPluginInfo plgx,
string strBuildPre, string strBuildPost)
{
if(strTmpRoot == null) { Debug.Assert(false); return null; }
RunBuildCommand(strBuildPre, UrlUtil.EnsureTerminatingSeparator(
strTmpRoot, false), null);
PlgxCsprojLoader.LoadDefault(strTmpRoot, plgx);
List<string> vCustomRefs = new List<string>();
foreach(string strIncRefAsm in plgx.IncludedReferencedAssemblies)
{
string strSrcAsm = plgx.GetAbsPath(UrlUtil.ConvertSeparators(
strIncRefAsm));
string strCached = PlgxCache.AddCacheFile(strSrcAsm, plgx);
if(string.IsNullOrEmpty(strCached))
throw new InvalidOperationException();
vCustomRefs.Add(strCached);
}
CompilerParameters cp = plgx.CompilerParameters;
cp.OutputAssembly = UrlUtil.EnsureTerminatingSeparator(strTmpRoot, false) +
UrlUtil.GetFileName(PlgxCache.GetCacheFile(plgx, false, false));
cp.GenerateExecutable = false;
cp.GenerateInMemory = false;
cp.IncludeDebugInformation = false;
cp.TreatWarningsAsErrors = false;
cp.ReferencedAssemblies.Add(WinUtil.GetExecutable());
foreach(string strCustomRef in vCustomRefs)
cp.ReferencedAssemblies.Add(strCustomRef);
CompileEmbeddedRes(plgx);
PrepareSourceFiles(plgx);
string[] vCompilers;
Version vClr = Environment.Version;
int iClrMajor = vClr.Major, iClrMinor = vClr.Minor;
if((iClrMajor >= 5) || ((iClrMajor == 4) && (iClrMinor >= 5)))
{
vCompilers = new string[] {
null,
"v4.5",
"v4", // Suggested in CodeDomProvider.CreateProvider doc
"v4.0", // Suggested in community content of the above
"v4.0.30319", // Deduced from file system
"v3.5"
};
}
else if(iClrMajor == 4) // 4.0
{
vCompilers = new string[] {
null,
"v4", // Suggested in CodeDomProvider.CreateProvider doc
"v4.0", // Suggested in community content of the above
"v4.0.30319", // Deduced from file system
"v4.5",
"v3.5"
};
}
else // <= 3.5
{
vCompilers = new string[] {
null,
"v3.5",
"v4", // Suggested in CodeDomProvider.CreateProvider doc
"v4.0", // Suggested in community content of the above
"v4.0.30319", // Deduced from file system
"v4.5"
};
}
CompilerResults cr = null;
StringBuilder sbCompilerLog = new StringBuilder();
bool bCompiled = false;
for(int iCmp = 0; iCmp < vCompilers.Length; ++iCmp)
{
if(CompileAssembly(plgx, out cr, vCompilers[iCmp]))
{
bCompiled = true;
break;
}
if(cr != null)
AppendCompilerResults(sbCompilerLog, vCompilers[iCmp], cr);
}
if(!bCompiled)
{
if(Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null)
SaveCompilerResults(plgx, sbCompilerLog);
throw new InvalidOperationException();
}
Program.TempFilesPool.Add(cr.PathToAssembly);
Debug.Assert(cr.PathToAssembly == cp.OutputAssembly);
string strCacheAsm = PlgxCache.AddCacheAssembly(cr.PathToAssembly, plgx);
//.........这里部分代码省略.........
开发者ID:riking,项目名称:go-keepass2,代码行数:101,代码来源:PlgxPlugin.cs
示例6: CreateFromDirectory
private static void CreateFromDirectory(string strDirPath)
{
string strPlgx = strDirPath + "." + PlgxExtension;
PlgxPluginInfo plgx = new PlgxPluginInfo(false, true, true);
PlgxCsprojLoader.LoadDefault(strDirPath, plgx);
FileStream fs = new FileStream(strPlgx, FileMode.Create,
FileAccess.Write, FileShare.None);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(PlgxSignature1);
bw.Write(PlgxSignature2);
bw.Write(PlgxVersion);
WriteObject(bw, PlgxFileUuid, (new PwUuid(true)).UuidBytes);
WriteObject(bw, PlgxBaseFileName, StrUtil.Utf8.GetBytes(
plgx.BaseFileName));
WriteObject(bw, PlgxCreationTime, StrUtil.Utf8.GetBytes(
TimeUtil.SerializeUtc(DateTime.Now)));
WriteObject(bw, PlgxGeneratorName, StrUtil.Utf8.GetBytes(
PwDefs.ShortProductName));
WriteObject(bw, PlgxGeneratorVersion, MemUtil.UInt64ToBytes(
PwDefs.FileVersion64));
string strKP = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqKP];
if(!string.IsNullOrEmpty(strKP))
{
ulong uKP = StrUtil.ParseVersion(strKP);
if(uKP != 0) WriteObject(bw, PlgxPrereqKP, MemUtil.UInt64ToBytes(uKP));
}
string strNet = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqNet];
if(!string.IsNullOrEmpty(strNet))
{
ulong uNet = StrUtil.ParseVersion(strNet);
if(uNet != 0) WriteObject(bw, PlgxPrereqNet, MemUtil.UInt64ToBytes(uNet));
}
string strOS = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqOS];
if(!string.IsNullOrEmpty(strOS))
WriteObject(bw, PlgxPrereqOS, StrUtil.Utf8.GetBytes(strOS));
string strPtr = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqPtr];
if(!string.IsNullOrEmpty(strPtr))
{
uint uPtr;
if(uint.TryParse(strPtr, out uPtr))
WriteObject(bw, PlgxPrereqPtr, MemUtil.UInt32ToBytes(uPtr));
}
string strBuildPre = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxBuildPre];
if(!string.IsNullOrEmpty(strBuildPre))
WriteObject(bw, PlgxBuildPre, StrUtil.Utf8.GetBytes(strBuildPre));
string strBuildPost = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxBuildPost];
if(!string.IsNullOrEmpty(strBuildPost))
WriteObject(bw, PlgxBuildPost, StrUtil.Utf8.GetBytes(strBuildPost));
WriteObject(bw, PlgxBeginContent, null);
RecursiveFileAdd(bw, strDirPath, new DirectoryInfo(strDirPath));
WriteObject(bw, PlgxEndContent, null);
WriteObject(bw, PlgxEOF, null);
bw.Close();
fs.Close();
// Test loading not possible, because MainForm not available
// PlgxPlugin.Load(strPlgx);
}
开发者ID:riking,项目名称:go-keepass2,代码行数:71,代码来源:PlgxPlugin.cs
示例7: ExtractFile
private static void ExtractFile(byte[] pbData, string strTmpRoot,
PlgxPluginInfo plgx)
{
MemoryStream ms = new MemoryStream(pbData, false);
BinaryReader br = new BinaryReader(ms);
string strPath = null;
byte[] pbContent = null;
while(true)
{
KeyValuePair<ushort, byte[]> kvp = ReadObject(br);
if(kvp.Key == PlgxfEOF) break;
else if(kvp.Key == PlgxfPath)
strPath = StrUtil.Utf8.GetString(kvp.Value);
else if(kvp.Key == PlgxfData) pbContent = kvp.Value;
else { Debug.Assert(false); }
}
br.Close();
ms.Close();
if(!string.IsNullOrEmpty(strPath) && (pbContent != null))
{
string strTmpFile = UrlUtil.EnsureTerminatingSeparator(strTmpRoot,
false) + UrlUtil.ConvertSeparators(strPath);
string strTmpDir = UrlUtil.GetFileDirectory(strTmpFile, false, true);
if(!Directory.Exists(strTmpDir)) Directory.CreateDirectory(strTmpDir);
byte[] pbDecompressed = MemUtil.Decompress(pbContent);
File.WriteAllBytes(strTmpFile, pbDecompressed);
// Although the temporary directory will be deleted recursively
// anyway, add the extracted file here manually, in order to
// minimize left-over files in case the recursive deletion fails
// due to locked / in-use files
Program.TempFilesPool.Add(strTmpFile);
if(plgx.LogStream != null)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] pbMD5 = md5.ComputeHash(pbDecompressed);
plgx.LogStream.Write(MemUtil.ByteArrayToHexString(pbMD5));
plgx.LogStream.WriteLine(" " + strPath);
}
}
else { Debug.Assert(false); }
}
开发者ID:riking,项目名称:go-keepass2,代码行数:50,代码来源:PlgxPlugin.cs
示例8: ReadFile
private static string ReadFile(BinaryReader br, PlgxPluginInfo plgx,
IStatusLogger slStatus)
{
uint uSig1 = br.ReadUInt32();
uint uSig2 = br.ReadUInt32();
uint uVersion = br.ReadUInt32();
if((uSig1 != PlgxSignature1) || (uSig2 != PlgxSignature2))
return null; // Ignore file, don't throw
if((uVersion & PlgxVersionMask) > (PlgxVersion & PlgxVersionMask))
throw new PlgxException(KLRes.FileVersionUnsupported);
string strPluginPath = null;
string strTmpRoot = null;
bool? bContent = null;
string strBuildPre = null, strBuildPost = null;
while(true)
{
KeyValuePair<ushort, byte[]> kvp = ReadObject(br);
if(kvp.Key == PlgxEOF) break;
else if(kvp.Key == PlgxFileUuid)
plgx.FileUuid = new PwUuid(kvp.Value);
else if(kvp.Key == PlgxBaseFileName)
plgx.BaseFileName = StrUtil.Utf8.GetString(kvp.Value);
else if(kvp.Key == PlgxCreationTime) { } // Ignore
else if(kvp.Key == PlgxGeneratorName) { }
else if(kvp.Key == PlgxGeneratorVersion) { }
else if(kvp.Key == PlgxPrereqKP)
{
ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
if(uReq > PwDefs.FileVersion64)
throw new PlgxException(KLRes.FileNewVerReq);
}
else if(kvp.Key == PlgxPrereqNet)
{
ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
ulong uInst = WinUtil.GetMaxNetFrameworkVersion();
if((uInst != 0) && (uReq > uInst))
throw new PlgxException(KPRes.NewerNetRequired);
}
else if(kvp.Key == PlgxPrereqOS)
{
string strOS = "," + WinUtil.GetOSStr() + ",";
string strReq = "," + StrUtil.Utf8.GetString(kvp.Value) + ",";
if(strReq.IndexOf(strOS, StrUtil.CaseIgnoreCmp) < 0)
throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
}
else if(kvp.Key == PlgxPrereqPtr)
{
uint uReq = MemUtil.BytesToUInt32(kvp.Value);
if(uReq > (uint)IntPtr.Size)
throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
}
else if(kvp.Key == PlgxBuildPre)
strBuildPre = StrUtil.Utf8.GetString(kvp.Value);
else if(kvp.Key == PlgxBuildPost)
strBuildPost = StrUtil.Utf8.GetString(kvp.Value);
else if(kvp.Key == PlgxBeginContent)
{
if(bContent.HasValue)
throw new PlgxException(KLRes.FileCorrupted);
string strCached = PlgxCache.GetCacheFile(plgx, true, false);
if(!string.IsNullOrEmpty(strCached) && plgx.AllowCached)
{
strPluginPath = strCached;
break;
}
if(slStatus != null)
slStatus.SetText(KPRes.PluginsCompilingAndLoading,
LogStatusType.Info);
bContent = true;
if(plgx.LogStream != null) plgx.LogStream.WriteLine("Content:");
}
else if(kvp.Key == PlgxFile)
{
if(!bContent.HasValue || !bContent.Value)
throw new PlgxException(KLRes.FileCorrupted);
if(strTmpRoot == null) strTmpRoot = CreateTempDirectory();
ExtractFile(kvp.Value, strTmpRoot, plgx);
}
else if(kvp.Key == PlgxEndContent)
{
if(!bContent.HasValue || !bContent.Value)
throw new PlgxException(KLRes.FileCorrupted);
bContent = false;
}
else { Debug.Assert(false); }
}
if((strPluginPath == null) && plgx.AllowCompile)
strPluginPath = Compile(strTmpRoot, plgx, strBuildPre, strBuildPost);
return strPluginPath;
//.........这里部分代码省略.........
开发者ID:riking,项目名称:go-keepass2,代码行数:101,代码来源:PlgxPlugin.cs
示例9: Compile
private static string Compile(string strTmpRoot, PlgxPluginInfo plgx,
string strBuildPre, string strBuildPost)
{
if(strTmpRoot == null) { Debug.Assert(false); return null; }
RunBuildCommand(strBuildPre, UrlUtil.EnsureTerminatingSeparator(
strTmpRoot, false), null);
PlgxCsprojLoader.LoadDefault(strTmpRoot, plgx);
List<string> vCustomRefs = new List<string>();
foreach(string strIncRefAsm in plgx.IncludedReferencedAssemblies)
{
string strSrcAsm = plgx.GetAbsPath(UrlUtil.ConvertSeparators(
strIncRefAsm));
string strCached = PlgxCache.AddCacheFile(strSrcAsm, plgx);
if(string.IsNullOrEmpty(strCached))
throw new InvalidOperationException();
vCustomRefs.Add(strCached);
}
CompilerParameters cp = plgx.CompilerParameters;
cp.OutputAssembly = UrlUtil.EnsureTerminatingSeparator(strTmpRoot,
false) + UrlUtil.GetFileName(PlgxCache.GetCacheFile(plgx.FileUuid,
false, false));
cp.GenerateExecutable = false;
cp.GenerateInMemory = false;
cp.IncludeDebugInformation = false;
cp.TreatWarningsAsErrors = false;
cp.ReferencedAssemblies.Add(WinUtil.GetExecutable());
foreach(string strCustomRef in vCustomRefs)
cp.ReferencedAssemblies.Add(strCustomRef);
CompileEmbeddedRes(plgx);
PrepareSourceFiles(plgx);
string[] vCompilers = new string[] {
null, "v3.5",
"v4", // Suggested in CodeDomProvider.CreateProvider doc
"v4.0" // Apparently works for most people
};
CompilerResults cr = null;
bool bCompiled = false;
for(int iCmp = 0; iCmp < vCompilers.Length; ++iCmp)
{
if(CompileAssembly(plgx, ref cr, vCompilers[iCmp]))
{
bCompiled = true;
break;
}
}
if(!bCompiled)
{
if(Program.CommandLineArgs[
AppDefs.CommandLineOptions.SavePluginCompileRes] != null)
SaveCompilerResults(plgx, cr);
throw new InvalidOperationException();
}
Program.TempFilesPool.Add(cr.PathToAssembly);
Debug.Assert(cr.PathToAssembly == cp.OutputAssembly);
string strCacheAsm = PlgxCache.AddCacheAssembly(cr.PathToAssembly, plgx);
RunBuildCommand(strBuildPost, UrlUtil.EnsureTerminatingSeparator(
strTmpRoot, false), UrlUtil.GetFileDirectory(strCacheAsm, true, false));
return strCacheAsm;
}
开发者ID:amiryal,项目名称:keepass2,代码行数:72,代码来源:PlgxPlugin.cs
示例10: CompileAssembly
private static bool CompileAssembly(PlgxPluginInfo plgx,
ref CompilerResults cr, string strCompilerVersion)
{
try
{
Dictionary<string, string> dictOpt = new Dictionary<string, string>();
if(!string.IsNullOrEmpty(strCompilerVersion))
dictOpt.Add("CompilerVersion", strCompilerVersion);
// Windows 98 only supports the parameterless constructor;
// check must be separate from the instantiation method
if(WinUtil.IsWindows9x) dictOpt.Clear();
CodeDomProvider cdp = null;
if(plgx.ProjectType == PlgxProjectType.CSharp)
cdp = ((dictOpt.Count == 0) ? new CSharpCodeProvider() :
CreateCscProvider(dictOpt));
// else if(plgx.ProjectType == PlgxProjectType.VisualBasic)
// cdp = ((dictOpt.Count == 0) ? new VBCodeProvider() :
// new VBCodeProvider(dictOpt));
else throw new InvalidOperationException();
cr = cdp.CompileAssemblyFromFile(plgx.CompilerParameters,
plgx.SourceFiles.ToArray());
return ((cr.Errors == null) || !cr.Errors.HasErrors);
}
catch(Exception) { }
// cr = null; // Keep previous results for output
return false;
}
开发者ID:amiryal,项目名称:keepass2,代码行数:32,代码来源:PlgxPlugin.cs
示例11: ReadImport
private static void ReadImport(XmlNode xn, PlgxPluginInfo plgx)
{
if(plgx.ProjectType != PlgxProjectType.VisualBasic) { Debug.Assert(false); return; }
XmlNode xnInc = xn.Attributes.GetNamedItem(XnnInclude);
if((xnInc == null) || string.IsNullOrEmpty(xnInc.Value)) { Debug.Assert(false); return; }
plgx.VbImports.Add(UrlUtil.ConvertSeparators(xnInc.Value));
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:9,代码来源:PlgxCsprojLoader.cs
示例12: CompileEmbeddedRes
private static void CompileEmbeddedRes(PlgxPluginInfo plgx)
{
foreach(string strResSrc in plgx.EmbeddedResourceSources)
{
string strResFileName = plgx.BaseFileName + "." + UrlUtil.ConvertSeparators(
UrlUtil.MakeRelativePath(plgx.CsprojFilePath, strResSrc), '.');
string strResFile = UrlUtil.GetFileDirectory(plgx.CsprojFilePath, true,
true) + strResFileName;
if(strResSrc.EndsWith(".resx", StrUtil.CaseIgnoreCmp))
{
PrepareResXFile(strResSrc);
string strRsrc = UrlUtil.StripExtension(strResFile) + ".resources";
ResXResourceReader r = new ResXResourceReader(strResSrc);
ResourceWriter w = new ResourceWriter(strRsrc);
r.BasePath = UrlUtil.GetFileDirectory(strResSrc, false, true);
foreach(DictionaryEntry de in r)
w.AddResource((string)de.Key, de.Value);
w.Generate();
w.Close();
r.Close();
if(File.Exists(strRsrc))
{
plgx.CompilerParameters.EmbeddedResources.Add(strRsrc);
Program.TempFilesPool.Add(strRsrc);
}
}
else
{
File.Copy(strResSrc, strResFile, true);
plgx.CompilerParameters.EmbeddedResources.Add(strResFile);
}
}
}
开发者ID:riking,项目名称:go-keepass2,代码行数:39,代码来源:PlgxPlugin.cs
示例13: ReadReference
private static void ReadReference(XmlNode xn, PlgxPluginInfo plgx)
{
XmlNode xnInc = xn.Attributes.GetNamedItem(XnnInclude);
if((xnInc == null) || string.IsNullOrEmpty(xnInc.Value)) { Debug.Assert(false); return; }
string str = xnInc.Value;
if(UrlUtil.AssemblyEquals(str, PwDefs.ShortProductName))
return; // Ignore KeePass references
foreach(XmlNode xnSub in xn.ChildNodes)
{
if(xnSub.Name == XnnHintPath)
{
plgx.IncludedReferencedAssemblies.Add(
UrlUtil.ConvertSeparators(xnSub.InnerText, '/'));
return;
}
}
if(!str.EndsWith(".dll", StrUtil.CaseIgnoreCmp)) str += ".dll";
plgx.CompilerParameters.ReferencedAssemblies.Add(str);
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:23,代码来源:PlgxCsprojLoader.cs
示例14: ReadPropertyGroup
private static void ReadPropertyGroup(XmlNode xn, PlgxPluginInfo plgx)
{
foreach(XmlNode xnChild in xn.ChildNodes)
{
if(xnChild.Name == XnnAssemblyName)
plgx.BaseFileName = xnChild.InnerText;
}
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:8,代码来源:PlgxCsprojLoader.cs
示例15: ReadProject
private static void ReadProject(XmlNode xn, PlgxPluginInfo plgx)
{
if(xn.Name != XnnProject) throw new Exception(KLRes.FileCorrupted);
foreach(XmlNode xnChild in xn.ChildNodes)
{
if(xnChild.Name == XnnPropertyGroup) ReadPropertyGroup(xnChild, plgx);
else if(xnChild.Name == XnnItemGroup) ReadItemGroup(xnChild, plgx);
}
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:10,代码来源:PlgxCsprojLoader.cs
示例16: ReadItemGroup
private static void ReadItemGroup(XmlNode xn, PlgxPluginInfo plgx)
{
foreach(XmlNode xnChild in xn.ChildNodes)
{
if(xnChild.Name == XnnEmbeddedRes) ReadEmbeddedRes(xnChild, plgx);
else if(xnChild.Name == XnnReference) ReadReference(xnChild, plgx);
else if(xnChild.Name == XnnCompile) ReadCompile(xnChild, plgx);
else if(xnChild.Name == XnnImport) ReadImport(xnChild, plgx);
}
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:10,代码来源:PlgxCsprojLoader.cs
示例17: CompileAssembly
private static bool CompileAssembly(PlgxPluginInfo plgx,
out CompilerResults cr, string strCompilerVersion)
{
cr = null;
const string StrCoreRef = "System.Core";
const string StrCoreDll = "System.Core.dll";
bool bHasCore = false, bCoreAdded = false;
foreach(string strAsm in plgx.CompilerParameters.ReferencedAssemblies)
{
if(UrlUtil.AssemblyEquals(strAsm, StrCoreRef))
{
bHasCore = true;
break;
}
}
if((strCompilerVersion != null) && strCompilerVersion.StartsWith(
"v", StrUtil.CaseIgnoreCmp))
{
ulong v = StrUtil.ParseVersion(strCompilerVersion.Substring(1));
if(!bHasCore && (v >= 0x0003000500000000UL))
{
plgx.CompilerParameters.ReferencedAssemblies.Add(StrCoreDll);
bCoreAdded = true;
}
}
bool bResult = false;
try
{
Dictionary<string, string> dictOpt = new Dictionary<string, string>();
if(!string.IsNullOrEmpty(strCompilerVersion))
dictOpt.Add("CompilerVersion", strCompilerVersion);
// Windows 98 only supports the parameterless constructor;
// check must be separate from the instantiation method
if(WinUtil.IsWindows9x) dictOpt.Clear();
CodeDomProvider cdp = null;
if(plgx.ProjectType == PlgxProjectType.CSharp)
cdp = ((dictOpt.Count == 0) ? new CSharpCodeProvider() :
CreateCscProvider(dictOpt));
// else if(plgx.ProjectType == PlgxProjectType.VisualBasic)
// cdp = ((dictOpt.Count == 0) ? new VBCodeProvider() :
// new VBCodeProvider(dictOpt));
else throw new InvalidOperationException();
cr = cdp.CompileAssemblyFromFile(plgx.CompilerParameters,
plgx.SourceFiles.ToArray());
bResult = ((cr.Errors == null) || !cr.Errors.HasErrors);
}
catch(Exception) { }
if(bCoreAdded)
plgx.CompilerParameters.ReferencedAssemblies.Remove(StrCoreDll);
return bResult;
}
开发者ID:riking,项目名称:go-keepass2,代码行数:59,代码来源:PlgxPlugin.cs
示例18: GetCacheFile
public static string GetCacheFile(PlgxPluginInfo plgx, bool bMustExist,
bool bCreateDirectory)
{
if(plgx == null) { Debug.Assert(false); return null; }
// byte[] pbID = new byte[(int)PwUuid.UuidSize];
// Array.Copy(pwPluginUuid.UuidBytes, 0, pbID, 0, pbID.Length);
// Array.Reverse(pbID);
// string strID = Convert.ToBase64String(pbID, Base64FormattingOptions.None);
// strID = StrUtil.AlphaNumericOnly(strID);
// if(strID.Length > 8) strID = strID.Substring(0, 8);
string strFileName = StrUtil.AlphaNumericOnly(plgx.BaseFileName);
if(strFileName.Length == 0) strFileName = "Plugin";
strFileName += ".dll";
string strDir = GetCacheDirectory(plgx, bCreateDirectory);
string strPath = strDir + Path.DirectorySeparatorChar + strFileName;
bool bExists = File.Exists(strPath);
if(bMustExist && bExists)
{
try { File.SetLastAccessTime(strPath, DateTime.Now); }
catch(Exception) { } // Might be locked by other KeePass instance
}
if(!bMustExist || bExists) return strPath;
return null;
}
开发者ID:rassilon,项目名称:keepass,代码行数:29,代码来源:PlgxCache.cs
示例19: SaveCompilerResults
private static void SaveCompilerResults(PlgxPluginInfo plgx,
StringBuilder sb)
{
string strFile = Path.GetTempFileName();
File.WriteAllText(strFile, sb.ToString(), StrUtil.Utf8);
MessageService.ShowWarning(plgx.BaseFileName,
"Compilation failed. Compiler results have been saved to:" +
Environment.NewLine + strFile);
}
开发者ID:riking,项目名称:go-keepass2,代码行数:10,代码来源:PlgxPlugin.cs
示例20: ReadEmbeddedRes
private static void ReadEmbeddedRes(XmlNode xn, PlgxPluginInfo plgx)
{
XmlNode xnInc = xn.Attributes.GetNamedItem(XnnInclude);
if((xnInc == null) || string.IsNullOrEmpty(xnInc.Value)) { Debug.Assert(false); return; }
string strResSrc = plgx.GetAbsPath(xnInc.Value); // Converts separators
plgx.EmbeddedResourceSources.Add(strResSrc);
}
开发者ID:haro-freezd,项目名称:KeePass,代码行数:8,代码来源:PlgxCsprojLoader.cs
注:本文中的KeePass.Plugins.PlgxPluginInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论