本文整理汇总了C#中KacTalk.ktString.IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# ktString.IsEmpty方法的具体用法?C# ktString.IsEmpty怎么用?C# ktString.IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KacTalk.ktString
的用法示例。
在下文中一共展示了ktString.IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetVariable
public bool SetVariable(ktString Name, ktValue Value, bool Add, bool Copy, bool IgnoreConstant)
{
// Nothing to use??
if (Name.IsEmpty() || (Value == null) || (m_Block == null))
{
return false;
}
return m_Block.SetVariable(Name, Value, Add, Copy, IgnoreConstant);
}
示例2: ktDelegateFunction
public ktDelegateFunction(ktString Name, ktFunction_Double_Delegate Delegate)
: base(Name, null, null, ktValue.Null)
{
m_Arguments = new ktList();
m_Arguments.Add(new ktValue("D", "double",
kacTalk.Main.GetClass("double"),
true, true));
m_Delegate = delegate(ktList Args)
{
if ((Args == null) || (Args.FirstNode == null) ||
(Args.FirstNode.Value == null))
{
throw new ktError("Didn't get an argument for '" +
Name + "'!", ktERR.MISSING);
}
//ktDebug.Log( "ktDF::DOUBLE(" +Args.FirstNode.Value.ToString() + ")" );
ktString S_In = new ktString(Args.FirstNode.Value.ToString());
double D_In = 0.0;
double D_Out = 0.0;
try
{
if (System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator == ",")
{
S_In.Replace(".", ",", true);
}
D_In = S_In.ToDouble();
}
catch (Exception E)
{
if (E.GetType() == typeof(System.FormatException) && !S_In.IsEmpty())
{
throw new ktError("ktDouble::CreateObject: Cant make '" + S_In + "' into an double", ktERR.WRONGTYPE);
}
}
ktDebug.Log("D_In: " + D_In.ToString());
D_Out = Delegate(D_In);
ktDebug.Log("D_Out: " + D_Out.ToString());
return new ktValue("return", "double",
kacTalk.Main.MakeObjectOf("double", D_Out),
true, true);
};
}
示例3: GetModule
/// <summary>
/// Get a module...
/// </summary>
public ktModule GetModule(ktString Name)
{
if (Name.IsEmpty())
{
return null;
}
ktModule Module = null;
if (m_Modules != null)
{
ktNode Node = m_Modules.GetNode(Name);
if ((Node != null) && (Node.Value != null))
{
Module = (ktModule)Node.Value;
}
}
if (Module == null)
{
throw new ktError("kactalk::GetModule() : There's no module with the name '" +
Name + "'!", ktERR.NOTDEF);
}
return Module;
}
示例4: ParseInfoString
public static Dictionary<ktString, ktString> ParseInfoString( ktString InfoStr )
{
int p = 0, p2 = 0;
ktString property;
ktString prop_name, prop_value;
Dictionary<ktString, ktString> InfoMap = new Dictionary<ktString, ktString>();
while (!InfoStr.IsEmpty())
{
p = InfoStr.IndexOf(';');
if (p < 0)
{
property = InfoStr;
p = InfoStr.Length() - 1;
}
else
{
property = InfoStr.SubString(0, p).Trim();
}
p2 = property.IndexOf('=');
prop_name = property.SubString(0, p2).AsUpper();
prop_value = property.SubString(p2 + 1);
InfoMap.Add(prop_name, prop_value);
InfoStr.Remove(0, p + 1);
InfoStr = InfoStr.Trim();
}
return InfoMap;
}
示例5: _RunMethod
public override ktValue _RunMethod(ktString Name, ktList Arguments)
{
if (Name.IsEmpty())
{
throw new ktError("Didn't get the name of the method to run in class '" +
m_Name + "'.", ktERR.NOTSET);
}
//ktDebug.Log( ";Name::"+ Name + ";;;;_\n" );
if (Name == "_PropertyChanged")
{
if ((Arguments == null) || (Arguments.GetCount() != 2))
{
throw new ktError("kactalk::_PropertyChanged() : Didn't get the two nnede arguments!",
ktERR.MISSING);
}
#if Debug
ktDebug.Log( "Args::" + Arguments.Get_R( "\t", true ) );
#endif
Name = Arguments.Get("Name").Node.Value.ToString();
ktValue Value = (ktValue)Arguments.Get("Value").Node.Value;
SetProperty(Name, Value);
return ktValue.Null;
}
else /*if (Name.StartsWith( "operator", out Name )) {
return HandleOperator( Name, Arguments );
} else */
{
throw new ktError("Couldn't find the method '" +
Name + "' in class '" + m_Name + "'.", ktERR._404);
}
}
示例6: SetProperty
public override ktValue SetProperty(ktString Name, ktValue Value)
{
if ((Name == "this") || (Name == "_this") ||
(Name == "object") || (Name == "_object") ||
(Name == "_") || (Name.IsEmpty()))
{
/*try {
m_Value = Convert.ToInt32( Value.ToString() );
} catch (Exception E) {
if (E.GetType() == typeof( System.FormatException )) {
throw new ktError( "kactalkClass::CreateObject: Cant make '" + Value + "' into an integer", ktERR.WRONGTYPE );
}
}*/
} /*else if (Name == "MathMode") {
// m_Value.MathMode = (((ktClass)Value.Value).ToString().ToLower() == "true");
m_Value.MathMode = Value.ToBool();
} */else
{
throw new ktError("Couldn't find the property '" +
Name + "' in class '" + m_Name + "'.", ktERR._404);
}
return GetProperty("_");
}
示例7: _RunMethod
public virtual ktValue _RunMethod(ktString Name, ktList Arguments)
{
//ktDebug.Log( "ktClass::_RM( " + Name + " );" );
if (Name.IsEmpty())
{
throw new ktError("Didn't get the name of the method to run in class '" +
m_Name + "'.", ktERR.NOTSET);
}
if (m_Methods == null)
{
throw new ktError("Couldn't find the method '" +
Name + "' in class '" + m_Name + "'.", ktERR._404);
}
ktNode Node = m_Methods.GetNode(Name);
if ((Node == null) || (Node.Value == null))
{
throw new ktError("Couldn't find the method '" +
Name + "' in class '" + m_Name + "'.", ktERR._404);
}
ktValue Value = ktValue.Null;
ktFunction Func = (ktFunction)Node.Value;
Value = Func.Run(Arguments);
return Value;
}
示例8: SetProperty
public virtual ktValue SetProperty(ktString Name, ktValue Value)
{
if (Name.IsEmpty())
{
throw new ktError("Didn't get the name of the property to change in class '" +
m_Name + "'.", ktERR.NOTSET);
}
if (m_Properties == null)
{
m_Properties = new ktList();
}
ktNode Node = m_Properties.GetNode(Name);
if ((Node == null) || (Node.Value == null))
{
if (m_AddIfNotSet)
{
return AddProperty(Name, Value);
}
else
{
throw new ktError("Couldn't find the property '" +
Name + "' in class '" + m_Name + "'.", ktERR._404);
}
}
else
{
ktValue Prop = (ktValue)Node.Value;
if (Prop.Constant)
{
throw new ktError("The property '" + Name + "' in class '" +
m_Name + "' is a constant and can't be changed.", ktERR.CONST);
}
else if (Value == null)
{
// HUM???
Prop.Value = null;
}
else
{
Prop.SetValue(Value);
}
return Prop;
}
}
示例9: GetProperty
public ktValue GetProperty(ktString Name, bool Copy)
{
ktValue Value = ktValue.Null;
if (Name.IsEmpty())
{
return Value;
}
//ktDebug.Log( "GetProperty( " + Name + " )" );
switch (Name.AsLower())
{
case "as_class":
case "class":
{
return new ktValue(Name, "ktClass", CreateClass(), true, true);
}
default:
{
//ktDebug.Log( "Default" );
Value = _GetProperty(Name, Copy);
break;
}
}
//ktDebug.Log( "Val = " + ((Value == null) ? "NULL" : Value.ToString() ) + " )" );
return Value;
}
示例10: Export
/// <summary>
/// Export the list...
/// </summary>
public override string Export()
{
ktString Str = new ktString("(");
ktString Name = new ktString(), Value = new ktString();
bool First = true;
Reset();
foreach (ktList List in this)
{
Name = "";
Value = "";
if (!First)
{
Str += ", \n";
}
else
{
First = false;
}
if (List.Node != null)
{
Name = List.Node.Name;
Value = List.Node.ExportValue();
}
if (!Name.IsEmpty())
{
if ((!Value.IsEmpty()) && (Value != ":null") && (!List.IsEmpty()))
{
//Name = "[\"" + Name + "\"," + Value + "]";
}
else
{
//Name = "\"" + Name + "\"";
//Name.Append( new ktString( Name.Len() ) );
}
}
else if (!Value.IsEmpty())
{
Name = Value;
Value = "";
}
if (!List.IsEmpty())
{
Value = List.Export();
}
else if ((Value.IsEmpty()) && (Name.IsEmpty()))
{
Value = ":null";
//Value = "\"" + Value + "\"";
}
if (!Name.IsEmpty())
{
Str += Name;
if (!Value.IsEmpty())
{
Str += " => " + Value;
}
}
else
{
Str += Value;
}
}
Str += ")";
return Str;
//return Get_R( Prefix, false );
}
示例11: CallCallback
protected void CallCallback(ktString Method)
{
if (Method.IsEmpty() || (m_Callback == null))
{
return;
}
ktList Args = new ktList();
Args.Add("Name", Name);
Args.Add("Value", this);
try
{
m_Callback.RunMethod("_" + Method, Args);
}
catch (ktError Err)
{
if ((Err.ErrorNumber != ktERR._404) && (Err.ErrorNumber != ktERR.NOTDEC))
{
throw Err;
}
}
}
示例12: SetName
public bool SetName(ktString Name)
{
if (Name.IsEmpty())
{
return false;
}
m_Name = Name;
return true;
}
示例13: Replace
public static ktList Replace(ktList Replacements, ktString Haystack)
{
ktList Results = new ktList();
ktString Pattern = new ktString();
ktString Replacement = new ktString();
ktRE_MatchEvaluator Ev = null;
ktNode Node;
ktString Result = "";
object First = null, Second = null;
Replacements.Reset();
foreach (ktList Post in Replacements)
{
if (Post.IsEmpty())
{
if ((Post.Node != null) && (Post.Node.Value != null))
{
Pattern = Post.Node.Name;
if ((Post.Node.Value.GetType() == typeof(ktString)) ||
(Post.Node.Value.GetType() == typeof(string)))
{
Replacement = Post.Node.Value.ToString();
Results.Add(Replace(Pattern, Haystack, Replacement));
}
else if (Post.Node.Value.GetType() == typeof(ktRE_MatchEvaluator))
{
Ev = (ktRE_MatchEvaluator)Post.Node.Value;
Results.Add(Replace(Pattern, Haystack, Ev));
}
else if (Post.Node.Value.GetType() == typeof(ktRegEx))
{
//ktRegEx RE = (ktRegEx)Post.Node.Value;
if (Pattern.IsEmpty())
{
//Results.Add( RE.Replace( Haystack, Ev ) );
}
else
{
//Results.Add( Replace( Pattern, Haystack, Ev ) );
}
}
}
}
else if (Post.Count == 2)
{
if ((Node = Post.GetNode(0)) != null)
{
First = Node.Value;
if ((Node = Post.GetNode(1)) != null)
{
Second = Node.Value;
}
}
if (Second != null)
{
if (First.GetType() == typeof(ktRegEx))
{
Result = HandleRegExFirst((ktRegEx)First, Second, Haystack);
Results.Add(Result);
}
else if (First.GetType() == typeof(ktString[]))
{
ktString[] Patterns = (ktString[])First;
foreach (ktString P in Patterns)
{
Result = HandleStringFirst(P, Second, Haystack);
Results.Add(Result);
}
}
else if (First.GetType() == typeof(ktList))
{
ktList Patterns = (ktList)First;
foreach (ktList P in Patterns)
{
if ((P.Node != null) && (P.Node.Value != null))
{
Pattern = P.Node.Value.ToString();
Result = HandleStringFirst(Pattern, Second, Haystack);
Results.Add(Result);
}
}
}
else /*if ((First.GetType() == typeof( ktString )) ||
(First.GetType() == typeof( string )))*/
{
Result = HandleStringFirst(First.ToString(), Second, Haystack);
Results.Add(Result);
}
}
}
}
return Results;
}
示例14: Scan
/// <summary>
/// Scan/Parse the script into tokens
/// </summary>
public bool Scan(ktString Script, ktString Name)
{
bool Ret = true;
Script.Replace("\r\n", "\n",true);
// Initiate the lineno.
m_CurLine = 1;
m_CharPos = 1;
// .. and name
m_Name = Name;
if (m_Tokens != null)
{
m_Tokens.Clear();
m_Tokens = null;
}
// Init...
ktString Line = new ktString();
int Pos = 0;
Script.Trim();
ktRegEx RE = new ktRegEx(ktToken.Separators);
// ... the block-stack
if (m_BlockStack != null)
{
m_BlockStack.Clear();
m_BlockStack = null;
}
m_BlockStack = new ktList();
// ... the token-list
if (m_Tokens != null)
{
m_Tokens.Clear();
m_Tokens = null;
}
m_Tokens = new ktList();
m_Tokens.Node = new ktNode("ktTStatement", new ktToken(ktTokenType.Statement, "", 0, 0));
// ... the token-stack
if (m_TokenStack != null)
{
m_TokenStack.Clear();
m_TokenStack = null;
}
m_TokenStack = new ktList();
// ... the lines (??)
if (m_Lines != null)
{
m_Lines.Clear();
m_Lines = null;
}
m_Lines = new ktList();
m_Lines.Node = new ktNode(Name, m_CurToken = new ktToken(ktTokenType.Program, Name, 0, 0));
// ... the line-stack
if (m_LineStack != null)
{
m_LineStack.Clear();
m_LineStack = null;
}
m_LineStack = new ktList();
if (m_MainBlock == null)
{
m_MainBlock = new ktBlock(new ktList());
}
else
{
if (m_MainBlock.Lines != null)
{
m_MainBlock.Lines.Clear();
}
m_MainBlock.ClearKTSymbols();
}
m_MainBlock.SetMain(this);
m_BlockStack.Add("ktTBlock", m_MainBlock);
/* In the "original scanner" (C++), we took one line (terminated by \n)
* at a time and worked on, now we just go through the line.
* And We hope that it will be much "leaner"!
*/
// Go on until the there's nothing left...
while (!Script.IsEmpty())
{
// Get the position for the next separator
Pos = RE.Find(Script);
// If there was none...
if (Pos < 0)
{
// Take it to the end...
Pos = Script.Len();
}
else if (Pos == 0)
{
Pos++;
//.........这里部分代码省略.........
示例15: GetVariable
/// <summary>
/// Get a variable
/// </summary>
public ktValue GetVariable(ktString Name)
{
if (Name.IsEmpty())
{
return null;
}
ktValue Var = null;
try
{
if (m_Variables != null)
{
ktNode Node = m_Variables.GetNode(Name);
if ((Node != null) && (Node.Value != null))
{
Var = (ktValue)Node.Value;
}
}
}
catch (ktError E)
{
if (!((E.ErrorNumber == ktERR.NOTFOUND) || (E.ErrorNumber == ktERR.NOTDEF)))
{
throw E;
}
}
if (Var == null)
{
throw new ktError("kactalk::GetVariable() : There's no variable with the name '" +
Name + "'!", ktERR.NOTDEF);
}
return Var;
}